[Issue 5353] clear function is calling the destructor twice

Craig Black craigblack2 at cox.net
Tue Dec 14 15:02:43 PST 2010


> --- Comment #1 from nfxjfg at gmail.com 2010-12-14 14:00:42 PST ---
> I think it's only because the GC calls the destructor AGAIN, when the 
> programs
> exits. This is as designed. First, the clear() function doesn't delete the
> object. Second, the GC calls dtors on all live objects on exit. Thus, the 
> dtor
> is called twice.
>
> So, this bug is likely INVALID.
>
> As for the clear() function, its design is an embarrassment.

I know this is not the case.  Try

struct A
{
   ~this() { writeln("here"); }
}

void main()
{
  A a;
  clear(a);
}

writes "here" 3 times. 



More information about the Digitalmars-d-bugs mailing list