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

Simen Kjaeraas <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #4 from Simen Kjaeraas <[email protected]> ---
The cause is the same - no inheritance is necessary. Allow me to demonstrate:

struct S1 {
    int value;
    ~this() {
        value = 17;
    }
}

struct S2 {
    S1 a;
    ~this() { }
}

unittest {
    S2 s;
    s.__dtor();

    // Would have been 17 if S1's destructor was run.
    assert(s.a.value == 0);

    // Note the existence of "__xdtor", which is a separate
    // method that calls member destructors.
    pragma(msg, __traits(allMembers, S2));

    s.__xdtor();
    assert(s.a.value == 17);
}



This clearly shows that S2's destructor does *not* call S1's destructor, and
thus that the code is valid. (it's validity may be undesired, but it's still
valid)

The only value of having this issue open in addition to issue 15246 would be if
15246 is inadequately described. If that's the case, 15246 should be amended,
not this issue.

*** This issue has been marked as a duplicate of issue 15246 ***

--

Reply via email to