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