[Issue 19505] New: C++ destructor mangling is wrong in the presence of inheritance
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Dec 21 14:27:33 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=19505
Issue ID: 19505
Summary: C++ destructor mangling is wrong in the presence of
inheritance
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: atila.neves at gmail.com
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.
--
More information about the Digitalmars-d-bugs
mailing list