Using emplace leading to memory corruption
lomereiter
lomereiter at gmail.com
Sun Sep 29 05:29:30 PDT 2013
You didn't tell GC that the allocated memory contains pointers to
GC'd data.
Therefore, it thinks that the class members can be freed, which
is not the case.
Adding lines
> import core.memory; GC.addRange(tmp, size);
resolves the problem. You must also call GC.removeRange(tmp) when
you will free the allocated memory.
> void[] mem = tmp[0..size]; // 39
> _foo = emplace!(Foo)(mem); // 40
More information about the Digitalmars-d
mailing list