[Issue 1001] print stack trace (in debug mode) when program die

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 11 15:17:20 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=1001



--- Comment #74 from Jonathan M Davis <jmdavisProg at gmx.com> 2014-01-11 15:16:45 PST ---
> It's a bigger topic amd opinions vary. AFAIK Errors skip cleanup code, but 
> it's possible to catch Errors to perform minimal cleanup.

According to Walter, there is no guarantee that any cleanup code is run when an
Error is thrown (though I'm not sure what the spec says on the matter).
However, some of the folks that believe that cleanup should be done on Errors
made it so that most cleanup code _is_ run when an Error is thrown. So, unless
something is changed, I believe that normally finally blocks, scope(exit),
scope(failure), and destructors will all be run when an Error is thrown. Where
they will get skipped is when an Error is thrown from a nothrow function, and
the cleanup code is outside the nothrow function, because the caller of the
nothrow function will assume that the nothrow function doesn't throw anything
and optimize based on that.

So, at this point, whether cleanup code is run on an Error depends on the code,
and at minimum, it will never be the case that cleanup code is always run on an
Error, because it won't be done for nothrow functions, or we lose the ability
to optimize it based on the fact that it won't throw an exception (which is one
its benefits). However, whether it will ever be changed such that cleanup code
is never run for Errors is an open question and a topic of hot debate.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list