https://issues.dlang.org/show_bug.cgi?id=15159
Issue ID: 15159
Summary: Static nested function prevent inlining
Product: D
Version: D2
Hardware: x86_64
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
Turns out that even _static_ nested function prevents inlining. Testing on
DMD-v2.069 HEAD.
Test case:
int boo()
{
pragma(inline, true);
static int foo(int k){ return k; }
return foo(1);
}
// needed else it will ignore inliner pass
unittest
{
assert(boo() == 1);
}
fails:
.\boo.d(1): Error: function boo.boo cannot inline function
While this works:
static int foo(int k){ return k; }
int boo()
{
pragma(inline, true);
return foo(1);
}
// needed else it will ignore inliner pass
unittest
{
assert(boo() == 1);
}
--