Showing with 17 additions and 1 deletion.
  1. +17 −1 src/rt/lifetime.d
18 changes: 17 additions & 1 deletion src/rt/lifetime.d
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ void finalize_array2(void* p, size_t size) nothrow
{
si = *cast(TypeInfo_Struct*)(p + size_t.sizeof);
size = *cast(size_t*)p;
p += LARGEPAD;
p += LARGEPREFIX;
}

try
Expand Down Expand Up @@ -2670,3 +2670,19 @@ unittest
import core.exception : InvalidMemoryOperationError;
assert(!test!InvalidMemoryOperationError);
}

// test bug 14126
unittest
{
static struct S
{
S* thisptr;
~this() { assert(&this == thisptr); thisptr = null;}
}

S[] test14126 = new S[2048]; // make sure we allocate at least a PAGE
foreach(ref s; test14126)
{
s.thisptr = &s;
}
}