RFC: Change what assert does on error

Sönke Ludwig sludwig at outerproduct.org
Sun Jun 29 19:16:34 UTC 2025


Am 29.06.2025 um 20:04 schrieb Richard (Rikki) Andrew Cattermole:
> What a couple of us are suggesting is that we change the default 
> behaviour from ``throw AssertError``.
> To: ``printBacktrace; exit(-1);``


This will be a serious issue for GUI applications where stderr will 
typically just go to /dev/null and then the application just 
inexplicably exits (an issue that we currently already encounter on user 
installations and so far it has been impossible to track down the 
source). Instead of `exit(-1)`, a much better choice would be `abort()`, 
which would at least trigger a debugger or the system crash report handler.

Regarding the assertion error message and the backtrace, it would be 
nice if there was some kind of hook to customize where the output goes. 
Generally redirecting stderr would be a possible workaround, but that 
comes with its own issues, especially if there is other output involved.


More information about the Digitalmars-d mailing list