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