RFC: Change what assert does on error

Sebastiaan Koppe mail at skoppe.eu
Tue Jul 8 06:20:55 UTC 2025


On Monday, 7 July 2025 at 21:54:23 UTC, Dukc wrote:
> On Monday, 7 July 2025 at 21:44:49 UTC, Dukc wrote:
>> I understand this is problematic, because in practice pretty 
>> much all code often is guarded by a top-level pokemon catcher, 
>> meaning destructor-relying memory safety isn't going to fly 
>> anywhere. I guess we should just learn to not do that
>
> Meant that should learn not to rely on destructors (or similar 
> finalisers) for memory safety.

I can see a perfect storm with destructors being skipped in 
combination with having stack memory in a multi-threaded program, 
so that the very act of skipping destructors is what _causes_ 
memory corruption. It breaks the structure the programmer 
diligently created.

If D can't gracefully shutdown a multi-threaded program when an 
Error occurs - i.e. catch the Error at the entry point of a 
thread, send upwards to the main thread and cancel any threads or 
other execution contexts (e.g. GPU) - then the only sane 
recommendation is to avoid all asserts or call abort on the spot. 
Which would be very unfortunate.


More information about the Digitalmars-d mailing list