[Issue 19843] New: Derived class has `__dtor` member if base class implements `~this()`

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri May 3 10:39:39 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=19843

          Issue ID: 19843
           Summary: Derived class has `__dtor` member if base class
                    implements `~this()`
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: slavo5150 at yahoo.com

class B
{
    ~this() {}
}

class C : B
{
    // NOTICE: No destructor   
}

void main()
{
    static assert(__traits(hasMember, B, "__dtor"));
    static assert(!__traits(hasMember, C, "__dtor"), "C should not have a
`__dtor` member"); 

    static assert(__traits(hasMember, B, "__xdtor"));
    static assert(__traits(hasMember, C, "__xdtor"));
}

Since `C` does not have an implementation for `~this()` it should not have a
`__dtor` member.  Both `B` and `C` should have an `__xdtor` member, though.

(At least that is my understanding)

--


More information about the Digitalmars-d-bugs mailing list