Bug 23890 – "Warning: cannot inline function" in core.lifetime
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-05-05T08:20:05Z
Last change time
2023-07-15T15:30:03Z
Keywords
pull
Assigned to
No Owner
Creator
Vladimir Panteleev
Comments
Comment #0 by dlang-bugzilla — 2023-05-05T08:20:05Z
This code produces a warning inside Druntime, that the user cannot do much about:
/////////////////////////// test.d ///////////////////////////
import core.lifetime;
auto fctr(alias fun, State...)(State state)
{
struct Pred
{
State state;
static if (state.length)
private this(State state)
{
static foreach (i; 0 .. state.length)
moveEmplace(state[i], this.state[i]);
}
auto opCall(this This, Args...)(auto ref Args args)
{
return fun(state, args);
}
}
static if (state.length)
return Pred(forward!state);
else
return Pred.init;
}
unittest
{
struct NC
{
@disable this();
@disable this(this);
int i;
this(int i) { this.i = i; }
}
auto f = fctr!((ref a, ref b) => a.i + b.i)(NC(2), NC(3));
assert(f() == 5);
}
//////////////////////////////////////////////////////////////
Command: dmd -o- -unittest -wi test.d
Output:
.../druntime/core/lifetime.d(1558): Warning: cannot inline function `test.__unittest_L30_C1.fctr!((ref a, ref b) => a.i + b.i, NC, NC).fctr.fwd!(_param_0).fwd`
.../druntime/core/lifetime.d(1558): Warning: cannot inline function `test.__unittest_L30_C1.fctr!((ref a, ref b) => a.i + b.i, NC, NC).fctr.fwd!(_param_1).fwd`
.../druntime/core/lifetime.d(2582): Warning: cannot inline function `core.lifetime.wipe!(NC).wipe`
Most likely introduced in https://github.com/dlang/druntime/pull/3653.
Comment #1 by dlang-bot — 2023-05-05T08:22:23Z
@CyberShadow created dlang/dmd pull request #15186 "Fix Issue 23890 - "Warning: cannot inline function" in core.lifetime" fixing this issue:
- Fix Issue 23890 - "Warning: cannot inline function" in core.lifetime
https://github.com/dlang/dmd/pull/15186
Comment #2 by dlang-bot — 2023-07-06T09:20:27Z
dlang/dmd pull request #15186 "Fix Issue 23890 - "Warning: cannot inline function" in core.lifetime" was merged into stable:
- 16920c5036e18fb616cfd6fb3f74f066b16f6c2c by Vladimir Panteleev:
Fix Issue 23890 - "Warning: cannot inline function" in core.lifetime
https://github.com/dlang/dmd/pull/15186
Comment #3 by dlang-bot — 2023-07-15T15:30:03Z
dlang/dmd pull request #15417 "merge stable" was merged into master:
- aef22a7b22eae60c73ba4cf9f0b2d130083cacdc by Vladimir Panteleev:
Fix Issue 23890 - "Warning: cannot inline function" in core.lifetime (#15186)
* Fix Issue 23890 - "Warning: cannot inline function" in core.lifetime
* druntime/test/profile: Divorce test from exact Druntime source numbers
Allow lines to move around in core/lifetime without affecting this test.
https://github.com/dlang/dmd/pull/15417