[Issue 18576] New: Compiler not doing RVO with auto returns
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Mar 7 23:46:29 UTC 2018
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 at puremagic.com
Reporter: bugzilla at 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
}
--
More information about the Digitalmars-d-bugs
mailing list