Arrays of noncopyables/Invalid memory operation

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Feb 18 17:18:33 PST 2016


On 02/18/2016 12:12 PM, Ali Çehreli wrote:

 >  > Hmm, why does the destructor of object 60 run in the middle of 
nowhere?
 >
 > It so happens that the GC decides to collect when moving the array to a
 > new location at that point. If you add the following to the beginning of
 > main, you will see that the next object to destroy is 59, then 58, etc.
 >
 >      import core.memory;
 >      GC.disable;
 >
 > So, everything makes sense other than throwing in a destructor having
 > issues with the current GC. :-/

No, it doesn't make sense to me anymore.

All we're doing here is growing an array. There shouldn't be any 
destructor calls when just doing that, no? As the array grows, the 
elements should be "moved" to the new location; why the destructor? I 
hope this is related to the recent fix.

Ali



More information about the Digitalmars-d-learn mailing list