Bug 21316 – NRVO not triggered for rvalue/ctor call

Status
NEW
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-10-16T07:24:19Z
Last change time
2024-12-13T19:12:11Z
Assigned to
No Owner
Creator
Eyal
Moved to GitHub: dmd#19806 →

Comments

Comment #0 by eyal — 2020-10-16T07:24:19Z
Example program: import std.stdio; struct S { this(int x) { writefln("%s", &this); } ~this() { writefln("%s", &this); } } unittest { auto f() { return S(1); } auto x = f(); } Running results in 2 different this ptrs, showing a copy had occurred: dmd -unittest -main -run testnrvo 7FFE98EAAD20 7FFE98EAAD48
Comment #1 by kinke — 2020-10-16T12:08:04Z
NRVO only triggers for lvalues (=> *named* return-value optimization); you're asking for RVO here.
Comment #2 by robert.schadek — 2024-12-13T19:12:11Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19806 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB