On Friday, 27 April 2012 at 13:13:20 UTC, Steven Schveighoffer
wrote:
Yes it's hard. The GC has no access to compile-time type
information. It relies on runtime information. The GC is able
to call the dtor for classes because classes store a pointer to
their typeinfo in the class instance itself (needed for virtual
functions).
But since structs do not have virtual functions, and many times
they are POD, this is not feasible. The allocator could
technically store the type info in the memory block, but it
doesn't. Strides recently have been made to make the GC more
precise, and in that effort, a path to solving this problem has
been opened up.
I suspect with precise GC work, this problem will be solved as
a side-effect. Maybe 6 months off, depending on how fervently
someone tries to add precise scanning ;)
-Steve
I see, that makes sense. Thanks.
I'm storing pointers to heap allocated structs in an AA to work
around issue 6178. I'll wrap them in a class instead, that should
work.