C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Exceptions : lost all hope -- do not resuscitate

From: Rainer Deyke <rainerd_at_[hidden]>
Date: Sun, 7 Jun 2026 00:52:46 +0200
On 6/6/26 20:03, Frederick Virchanza Gotham via Std-Proposals wrote:
> "If a mutex fails to lock, the entire process is fried"
I don't think that's necessarily the case, although the C++ standard is
spectacularly unhelpful about what situations can cause a lock operation
to fail and what the resulting std::error_code would look like. In some
cases (where the failure to lock is actually considered likely), it may
be possible to fall back to a single threaded code path. In others, at
least an exception gives the process the opportunity to clean up after
itself, i.e. delete its temporary files, flush its log files, and
properly close its network connections.

(The only specifically documented case where an exception could be
thrown, on the other hand, truly is unrecoverable. If locking would
deadlock, then the program has already entered undefined behavior and no
recovery is possible.)


-- 
Rainer Deyke - rainerd_at_[hidden]

Received on 2026-06-06 22:52:57