Bug 22089 – inline messes up RVO-ed object

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2021-06-28T15:17:29Z
Last change time
2024-12-13T19:17:23Z
Assigned to
No Owner
Creator
Sebastiaan Koppe
Moved to GitHub: dmd#18043 →

Comments

Comment #0 by mail — 2021-06-28T15:17:29Z
In the concurrency package I am relying on RVO being performed, essentially I want to ensure placement of a struct on the callee's stack. I am aware I cannot get 100% guarantee of RVO since the compiler is free to perform a blit anywhere it likes. Regardless, I have tests that ensure it applies RVO. It works fine on all 3 compilers until I turn on DMD's -inline. I am aware RVO isn't guaranteed to be performed, but since it works fine without inlining, I suspect there is something afoul there (since, by definition, if it is inlined it need not blit anymore). As a workaround I am using NVRO. --- struct S { @disable this(ref return scope typeof(this) rhs); @disable this(this); void* cons; this(int i) { cons = cast(void*)&this; } void start() { void* s = cast(void*)&this; assert(cons == s); // fails on dmd when build with -inline } } auto fun() { // auto s = S(42); // NVRO does work though... // return s; return S(42); } void main() { auto op = fun(); op.start(); } ---
Comment #1 by robert.schadek — 2024-12-13T19:17:23Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18043 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB