Bug 22966 – Inconsistent `shared` attribute for generated destructor

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-04-01T12:18:14Z
Last change time
2024-12-13T19:21:55Z
Keywords
industry
Assigned to
No Owner
Creator
kinke
Moved to GitHub: dmd#18096 →

Comments

Comment #0 by kinke — 2022-04-01T12:18:14Z
The `shared` attribute for a generated destructor seems NOT to depend on the aggregate alone: ``` struct WithDtor { int x; ~this() {} } struct A { WithDtor withDtor; } struct B { version (Shared) shared A a; else A a; } struct C { A a; } void main() { B b; pragma(msg, A.__xdtor.mangleof); } ``` With DMD v2.099: ``` $ dmd -o- foo.d _D3mod1A11__fieldDtorMFZv $ dmd -o- foo.d -version=Shared _D3mod1A11__fieldDtorMOFZv ``` This leads to linker errors in real-world code.
Comment #1 by kinke — 2022-04-01T12:26:09Z
Trying to work around this with an explicit dummy ctor does NOT work: ``` struct WithDtor { int x; ~this() {} } struct A { WithDtor withDtor; ~this() shared {} } struct B { version (Shared) shared A a; else A a; } void main() { pragma(msg, A.__xdtor.mangleof); } ``` ``` $ dmd -o- foo.d _D3mod1A10__aggrDtorMFZv $ dmd -o- foo.d -version=Shared _D3mod1A10__aggrDtorMOFZv ```
Comment #2 by kinke — 2022-04-01T12:41:12Z
One more WTF: ``` struct WithDtor { int x; ~this() {} } struct A { WithDtor withDtor; } pragma(msg, A.__xdtor.mangleof); struct B { shared A a; } void main() { pragma(msg, A.__xdtor.mangleof); } ``` ``` _D3mod1A11__fieldDtorMFZv _D3mod1A11__fieldDtorMOFZv ```
Comment #3 by robert.schadek — 2024-12-13T19:21:55Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18096 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB