F*cked by memory corruption after assiging value to associative array

Ali Çehreli acehreli at yahoo.com
Mon Jan 25 16:46:34 UTC 2021


On 1/25/21 8:14 AM, vitamin wrote:

 > If created on the default way mean allocated with new (=> GC)

I had the same thought. The following would be the "default way" for me 
but passing that object's address to addRoot would be wrong:

import core.memory;

struct S {
}

void main() {
   auto a = S();
   GC.addRoot(&a); // Wrong: 'a' is on the stack
}

I'm pretty sure frame knows this but still...

Ali



More information about the Digitalmars-d-learn mailing list