www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19505] New: C++ destructor mangling is wrong in the presence


          Issue ID: 19505
           Summary: C++ destructor mangling is wrong in the presence of
           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

// cpp.cpp
class Base {
    virtual ~Base() { }

class Derived: public Base {
    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

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.

Dec 21 2018