Dynamic arrays, emplace and GC

Rene Zwanenburg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 5 07:56:28 PDT 2016


On Tuesday, 5 July 2016 at 13:48:46 UTC, Claude wrote:
> Ah ok. I tried using void[size] static array and it seems to 
> work without having to use GC.addRange().

Correct. void[] means the type of the data is unknown, so the GC 
has to assume it can contain pointers.

This also means that _everything_ in any void buffer has to be 
treated as a potential pointer. In other words, if you allocate a 
void buffer and fill it with ints, and one of those ints happens 
to have a value equal to the address of a GC-allocated object, 
the GC will assume the int is a pointer to that object and not 
free it.


More information about the Digitalmars-d-learn mailing list