Bug 14164 – trivial lambdas are not inlined

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-02-10T10:01:00Z
Last change time
2015-02-10T14:53:04Z
Assigned to
nobody
Creator
bugzilla

Comments

Comment #0 by bugzilla — 2015-02-10T10:01:41Z
import std.stdio; void foo() @system { writeln("foo"); } void main() @safe { () @trusted { foo(); } (); } // dmd -inline -O -g test.d Breakpoint 1, D main () at test.d:10 10 () @trusted { foo(); } (); (gdb) disassemble Dump of assembler code for function _Dmain: 0x000000000046d3f0 <+0>: push %rbp 0x000000000046d3f1 <+1>: mov %rsp,%rbp => 0x000000000046d3f4 <+4>: callq 0x46d400 <_D4test4mainFNfZ9__lambda1FNeZv> 0x000000000046d3f9 <+9>: xor %eax,%eax 0x000000000046d3fb <+11>: pop %rbp 0x000000000046d3fc <+12>: retq End of assembler dump.\ As you may see in generated call it actually calls lambda function (_D4test4mainFNfZ9__lambda1FNeZv) instead of calling _D4test3fooFZv directly
Comment #1 by schveiguy — 2015-02-10T14:53:04Z
*** This issue has been marked as a duplicate of issue 10848 ***