[Issue 19602] Under some circumstances: throwing Error subclasses unwinds without invoking dtors

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 21 23:45:49 UTC 2019


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

--- Comment #1 from Eyal <eyal at weka.io> ---
If "Errors" mean "bugs" - then it should not unwind the stack and allow catch()
handlers to catch them and resume execution, as dtors will be skipped.

If error throwing is fine, then "nothrow" should NOT imply no auto-generated
exception handling code. It becomes useful only as a declaration of intent for
the user, and not useful to the compiler.

As long as this bug exists, there's a choice between these 2 options:

* Errors should never really be caught - as they run in a completely broken
state.

* Destructors cannot be trusted in the general case.

I see 2 possible fixes:

* Ignore nothrow in the compiler codegen. Assume errors can always be thrown,
even in nothrow (indeed they can).

* Replace throwing/catching Errors with a different mechanism to signal/handle
errors without incorrect stack unwinding.

--


More information about the Digitalmars-d-bugs mailing list