The GC, destructors, exceptions and memory corruption

Michel Fortin michel.fortin at michelf.com
Fri May 13 08:06:35 PDT 2011


On 2011-05-13 09:44:33 -0400, Don <nospam at nospam.com> said:

> If the GC calls it, it's a finalizer, not a destructor.
> 
> Structs have destructors, and it's perfectly OK to throw inside them.

Really? What if you allocated the struct on the heap, as a member of a 
class, or in an array? The struct will be on the heap and its 
destructor will become the finalizer.

What you say about structs makes sense only as long as structs are 
confined to the stack. In reality, structs can also be on the heap.

Discussion for bug 4621's has a long discussion about this issue.
<http://d.puremagic.com/issues/show_bug.cgi?id=4621>

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



More information about the Digitalmars-d mailing list