Arrays of noncopyables/Invalid memory operation

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


On 02/17/2016 07:00 PM, ZombineDev wrote:
 > On Thursday, 18 February 2016 at 01:19:16 UTC, Ali Çehreli wrote:
 >> On 02/17/2016 05:14 PM, ZombineDev wrote:
 >>
 >> > The "Invalid memory operation" error is thrown only by the GC
 >> (AFAIK)
 >> > when the user tries something unsupported like allocating or
 >> freeing in
 >> > a destructor, while a GC collection is being run.
 >>
 >> That. The problem is when the assert check fails (for value==60). The
 >> GC fails to create the exception object.

I found an open issue that depends on changing the GC implementation:

   https://issues.dlang.org/show_bug.cgi?id=7349

 > 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. :-/

Ali



More information about the Digitalmars-d-learn mailing list