Destructor semantics

Michel Fortin michel.fortin at michelf.com
Tue Aug 10 15:51:01 PDT 2010


On 2010-08-10 18:39:03 -0400, "Steven Schveighoffer" 
<schveiguy at yahoo.com> said:

> It's only safe if the struct destructor does not deallocate any heap data.

To be even clearer, it's only safe if the struct destructor doesn't 
access any heap data through one of its members.

And accessing an array or a string could potentially count as accessing 
heap data too (unless you can be sure it wasn't from the GC-heap).

So destructors called during the collection cycle are a very tricky 
thing to handle.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list