Bug 18516 – Add -vnrvo switch for showing user when nrv is done

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-02-24T10:00:15Z
Last change time
2024-12-13T18:57:24Z
Assigned to
No Owner
Creator
Iain Buclaw
Moved to GitHub: dmd#17845 →

Comments

Comment #0 by ibuclaw — 2018-02-24T10:00:15Z
This optimization is practically undocumented, save for the glossary, and the existing checks for NRVO in the D2 testsuite are really quite fragile as the test for it is checking what is effectively undefined behaviour in normal circumstances. i.e: What `p` is pointing to here is not known, as `tmp` is no longer in scope when the assert() contract is executed. --- static S* p; S fn() { S tmp; p = &tmp; return tmp; } S s = fn(); assert(p == &s); --- So there's also a desire for a better way to test NRVO in the compiler, this could be done by validating an AST dump of the backend codegen, but using the existing TEST_OUTPUT support should be simpler.
Comment #1 by robert.schadek — 2024-12-13T18:57:24Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17845 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB