https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96156
Bug ID: 96156 Summary: d: No RVO when returning struct literals initialized with constructor. Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: d Assignee: ibuclaw at gdcproject dot org Reporter: ibuclaw at gdcproject dot org Target Milestone: --- The address of 's' should become the 'this' pointer of the __ctor() call. struct S66 { int x; __gshared void* ptr; @disable this(this); this(int x) { ptr = &this; this.x = x; } } auto f66() { return g66(); } auto g66() { return h66(); } auto h66() { return S66(100); } void main() { auto s = f66(); assert(&s == S66.ptr); }