Bug 11224 – Inlining stops NRVO

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-10-11T03:21:00Z
Last change time
2013-11-08T00:07:30Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
k.hara.pg

Comments

Comment #0 by k.hara.pg — 2013-10-11T03:21:24Z
Test code: ------------ extern(C) int printf(const char*, ...); struct S { this(int) { printf("ctor &this = %p\n", &this); } int num; } S foo() { S s = S(1); printf("foo &this = %p\n", &s); return s; } void main() { auto s = foo(); printf("main &this = %p\n", &s); } Output: ------------ $ dmd -run test ctor &this = 0012FE20 foo &this = 0012FE20 main &this = 0012FE20 ------------ $ dmd -inline -run test ctor &this = 0012FE1C foo &this = 0012FE1C main &this = 0012FE18 // variable is moved!
Comment #1 by k.hara.pg — 2013-10-11T03:24:11Z
Comment #2 by github-bugzilla — 2013-11-08T00:06:36Z