December 21, 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@puremagic.com
          Reporter: atila.neves@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.

--