← Back to index
|
Original Bugzilla link
Bug 18576 – Compiler not doing RVO with auto returns
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-03-07T23:46:29Z
Last change time
2018-03-11T05:39:27Z
Assigned to
No Owner
Creator
Walter Bright
See also
https://issues.dlang.org/show_bug.cgi?id=17448
Comments
Comment #0
by bugzilla — 2018-03-07T23:46:29Z
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 }
Comment #1
by bugzilla — 2018-03-09T09:14:54Z
https://github.com/dlang/dmd/pull/7990
Comment #2
by bugzilla — 2018-03-11T00:32:13Z
*** Issue 17318 has been marked as a duplicate of this issue. ***
Comment #3
by github-bugzilla — 2018-03-11T05:39:26Z
Commits pushed to master at
https://github.com/dlang/dmd
https://github.com/dlang/dmd/commit/94f0bd6af7120ff27968052ad5645a554db12bed
fix Issue 18576 - Compiler not doing RVO with auto returns
https://github.com/dlang/dmd/commit/8b51a1d3d6f2c96214da0b3e49a62c1b021a70b0
Merge pull request #7990 from WalterBright/fix18576 fix Issue 18576 - Compiler not doing RVO with auto returns merged-on-behalf-of: Walter Bright <
[email protected]
>