The GC, destructors, exceptions and memory corruption
Michel Fortin
michel.fortin at michelf.com
Fri May 13 11:16:00 PDT 2011
On 2011-05-13 13:16:03 -0400, Max Samukha <maxter at spambox.com> said:
> On 05/13/2011 04:44 PM, Don wrote:
>> If the GC calls it, it's a finalizer, not a destructor.
>>
>> Structs have destructors, and it's perfectly OK to throw inside them.
>
> Destructor/finalizer confusion is one of D's weakest spots. GC and
> "delete" (now - "clear") should have never been designed to call the
> same function. Now that there are talks about making GC call
> destructors on structs, structs are at the threat of becoming as broken
> as classes are.
They're already broken in subtle and racy ways because of this. A few examples:
<http://d.puremagic.com/issues/show_bug.cgi?id=4624>
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list