[Issue 13586] Destructors not run when argument list evaluation throws

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Oct 13 21:33:31 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13586

--- Comment #7 from Walter Bright <bugzilla at digitalmars.com> ---
(In reply to Andrei Alexandrescu from comment #5)
> (In reply to Walter Bright from comment #3)
> > (In reply to Sobirari Muhomori from comment #1)
> > > Shouldn't the argument be destructed by the caller when the callee returns?
> > 
> > Yes. Once the function gets called, it gets marked by the compiler as "don't
> > destroy this".
> 
> Wait, I'm confused. On the normal path (no exceptions) isn't the callee
> destroying its by-value arguments?

Yes. If the function doesn't get called, then the caller has to call the
destructors on the partially constructed argument list. If the function does
get called, then the function destroys the arguments.

Hence having the compiler mark it to be careful where the destructor code gets
placed.

--


More information about the Digitalmars-d-bugs mailing list