digitalmars.D.bugs - [Issue 18516] New: Add -vnrvo switch for showing user when nrv is done
- d-bugmail puremagic.com (35/35) Feb 24 2018 https://issues.dlang.org/show_bug.cgi?id=18516
https://issues.dlang.org/show_bug.cgi?id=18516 Issue ID: 18516 Summary: Add -vnrvo switch for showing user when nrv is done Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: ibuclaw gdcproject.org 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. --
Feb 24 2018