dmd/compiler/test/runnable/test24139.d
Martin Kinkelin fbafba8790
Fix Issue 24139 - 'this' corruption in extern(C++) dtor when destructing via TypeInfo_Struct (#15598)
For the `TypeInfo_Struct.xdtor` field, the linkage of the aggregate
itself plays no role; it's the linkage of the destructor that matters.

A real-life example for this is DMD's own `OutBuffer`.
2023-09-11 10:55:13 +03:00

25 lines
325 B
D

// https://issues.dlang.org/show_bug.cgi?id=24139
struct S1
{
int x;
extern(C++) ~this() { assert(&this == s1); }
}
extern(C++) struct S2
{
int x;
~this() { assert(&this == s2); }
}
S1* s1;
S2* s2;
void main()
{
s1 = new S1;
s2 = new S2;
typeid(S1).destroy(s1);
typeid(S2).destroy(s2);
}