Bug 19505 – C++ destructor mangling is wrong in the presence of inheritance

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-12-21T14:27:33Z
Last change time
2024-12-13T19:01:41Z
Keywords
C++, link-failure, mangling
Assigned to
No Owner
Creator
Atila Neves
Moved to GitHub: dmd#17889 →

Comments

Comment #0 by atila.neves — 2018-12-21T14:27:33Z
There's no way currently to link to the following C++ code, especially due to https://issues.dlang.org/show_bug.cgi?id=19504: -------- // cpp.cpp class Base { public: virtual ~Base() { } }; class Derived: public Base { public: virtual ~Derived() { } }; -------- -------- // d.d extern(C++) { class Base { ~this(); } class Derived: Base { ~this(); } } -------- The destructor symbols dmd emits for the D declarations are, respectively, _ZN4BaseD1Ev and _ZN7DerivedD1Ev. The C++ compiler emits _ZN4BaseD2Ev and _ZN7DerivedD2Ev. According to the Itanium ABI, D is emitting symbols for "complete object destructors" whereas the C++ versions are "base object destructors" (the C++ compiler also emits symbols with a "D0" that are "deleting destructors"). The situation gets worse when there are no virtual functions and it's C++ structs inheriting from each other. There's no way to link, and it happens in the C++ standard library.
Comment #1 by atila.neves — 2018-12-22T13:38:44Z
It seems this only happens with clang. gcc emits all 3 destructors for each type: deleting, base and complete.
Comment #2 by robert.schadek — 2024-12-13T19:01:41Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17889 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB