Date: Wed, 28 Feb 2024 21:34:42 +0000
On Wed, Feb 28, 2024 at 4:57 PM Jonathan Wakely wrote:
>
> It doesn't belong in the standard.
The Standard could succinctly mandate the behaviour of the 'throw
handler' and make it very easy to log all exceptions. It would even be
very easy to detect if the 'throw handler' itself throws an exception
(and perhaps respond by calling 'terminate'), as follows:
void _CxxThrowException(void *const p, ThrowInfo const *const pti)
{
static thread_local bool already_entered = false;
if ( already_entered ) std::terminate();
already_entered = true;
if ( nullptr != throw_handler ) throw_handler(p, ti);
already_entered = false;
// Remainder of _CxxThrowException code goes here
}
>
> It doesn't belong in the standard.
The Standard could succinctly mandate the behaviour of the 'throw
handler' and make it very easy to log all exceptions. It would even be
very easy to detect if the 'throw handler' itself throws an exception
(and perhaps respond by calling 'terminate'), as follows:
void _CxxThrowException(void *const p, ThrowInfo const *const pti)
{
static thread_local bool already_entered = false;
if ( already_entered ) std::terminate();
already_entered = true;
if ( nullptr != throw_handler ) throw_handler(p, ti);
already_entered = false;
// Remainder of _CxxThrowException code goes here
}
Received on 2024-02-28 21:34:55