[Issue 19602] Under some circumstances: throwing Error subclasses unwinds without invoking dtors
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jan 22 02:21:47 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=19602
Mathias LANG <pro.mathias.lang at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pro.mathias.lang at gmail.com
Severity|critical |normal
--- Comment #2 from Mathias LANG <pro.mathias.lang at gmail.com> ---
This behavior is documented in the language specs since the very beginning of
D2.
In fact, there is currently a bug opened by Walter because dtors and `scope`
statements are executed: https://issues.dlang.org/show_bug.cgi?id=17494
In addition, there is a PR to fix said issue:
https://github.com/dlang/dmd/pull/6896
There is still value in catching `Error` though: as a last resort mesure:
catch, log & abort is one thing, and catching at the top of a thread/fiber to
avoid the program termination is another.
Note that if `nothrow` applied to Error, the attribute would be essentially
useless: `assert`, `new`, `switch`, slice casts and many other things could not
be `nothrow`.
--
More information about the Digitalmars-d-bugs
mailing list