digitalmars.D.bugs - [Issue 18576] New: Compiler not doing RVO with auto returns
- d-bugmail puremagic.com (42/42) Mar 07 2018 https://issues.dlang.org/show_bug.cgi?id=18576
https://issues.dlang.org/show_bug.cgi?id=18576 Issue ID: 18576 Summary: Compiler not doing RVO with auto returns Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: bugzilla digitalmars.com As reported by Tomer Filiba: void delegate() callback; struct S { int x; disable this(this); this(int x) { this.x = x; callback = &inc; } void inc() { x++; } } auto f() { return g(); // RVO not done } auto g() { return h(); // RVO not done } auto h() { return S(100); } void main() { auto s = f(); writeln(&s, " ", callback.ptr); // 7FFF0C838400 7FFF0C8383A0 callback(); writeln(s.x); // 100 instead of 101 } --
Mar 07 2018