From 21aba9efeaf9eacd7da3d2585519b083355b9b78 Mon Sep 17 00:00:00 2001 From: Steven Schveighoffer Date: Fri, 6 Feb 2015 10:37:34 -0500 Subject: [PATCH] Fixed issue 14126 -- Used wrong constant for offset when finalizing a large array. --- src/rt/lifetime.d | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/rt/lifetime.d b/src/rt/lifetime.d index b3a7960315f..f0ad19ec288 100644 --- a/src/rt/lifetime.d +++ b/src/rt/lifetime.d @@ -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 @@ -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; + } +}