https://issues.dlang.org/show_bug.cgi?id=20285
kinke <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #1 from kinke <[email protected]> --- This shows better what's going on: void main() { Foo[] array; array.length = 1; array[0] = Foo(1); printf("1st pointer: %p\n", array.ptr); array.length = 2; array[1] = Foo(2); printf("2nd pointer: %p\n", array.ptr); } => Destroying foo 0 1st pointer: 0x7f9cf69b3000 Destroying foo 0 2nd pointer: 0x7f9cf69b4000 Destroying foo 1 Destroying foo 2 Destroying foo 1 Increasing the length default-constructs instances at the end, which are destructed when assigning the literals later. These are the first 2 dtor calls. As a reallocation takes places, the two GC arrays are destructed on program termination, these are the other 3 dtor calls. Here, the 1st 1-element-array should probably not be destructed, as it's been moved from (and it hasn't been reset to T.init either). --
