Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
fix Issue 14746 - Behavior change with struct destructor and alias this
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Jul 1, 2015
1 parent 02e1c44 commit 1a2290b
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/object.d
Expand Up @@ -2229,7 +2229,11 @@ private void _destructRecurse(S)(ref S s)
import core.internal.traits : hasElaborateDestructor;

static if (__traits(hasMember, S, "__dtor"))
s.__dtor();
{
// Bugzilla 14746: Check that it's the exact member of S.
static if (__traits(isSame, S, __traits(parent, s.__dtor)))
s.__dtor();
}

foreach_reverse (ref field; s.tupleof)
{
Expand Down Expand Up @@ -2391,6 +2395,24 @@ nothrow @safe @nogc unittest
assert(i == 42);
}

unittest
{
// Bugzilla 14746
static struct HasDtor
{
~this() { assert(0); }
}
static struct Owner
{
HasDtor* ptr;
alias ptr this;
}

Owner o;
assert(o.ptr is null);
destroy(o); // must not reach in HasDtor.__dtor()
}

// Test handling of fixed-length arrays
// Separate from first test because of @@@BUG@@@ 14242
unittest
Expand Down

0 comments on commit 1a2290b

Please sign in to comment.