digitalmars.D.bugs - [Issue 22552] New: moveEmplace wipes context pointer of nested
- d-bugmail puremagic.com (35/35) Nov 29 2021 https://issues.dlang.org/show_bug.cgi?id=22552
https://issues.dlang.org/show_bug.cgi?id=22552 Issue ID: 22552 Summary: moveEmplace wipes context pointer of nested struct contained in non-nested struct Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: druntime Assignee: nobody puremagic.com Reporter: stanislav.blinov gmail.com import core.lifetime; void main() { int i; struct Nested { ~this() { ++i; } } static struct NotNested { Nested n; } auto a = NotNested(Nested()); // when this is destructed things go boom... NotNested b = void; moveEmplace(a, b); // ...because this wipes context pointer in a.n } // segmentation fault --- That's because moveEmplace simply blits NotNested.init into a. Instead it probably should move things fieldwise and avoid wiping context pointers in fields that are nested structs. --
Nov 29 2021