Date: Thu, 29 Feb 2024 11:53:26 +0100
I agree with Jonathan; this does not belong in the standard. For
starters, it makes optimizations impossible such as eliminating:
> try {
> throw 0;
> } catch (...) {}
While compilers aren't very good at eliminating unnecessary try/catch
yet, they should be allowed to do it. If you make it so that throwing
inevitably calls a global handler, this optimization becomes entirely
impossible, since any throw might have observable side effects.
I'm also confident that given enough time (perhaps not C++26, but
eventually) constexpr exception handling will be a thing. It's unclear
how that would work when there is global mutable state in the form of
a throw handler. Global mutable state doesn't really exist in constant
expressions.
It's irrelevant how quickly you could hack together something that
works in a specific implementation. This doesn't belong in the C++
standard.
starters, it makes optimizations impossible such as eliminating:
> try {
> throw 0;
> } catch (...) {}
While compilers aren't very good at eliminating unnecessary try/catch
yet, they should be allowed to do it. If you make it so that throwing
inevitably calls a global handler, this optimization becomes entirely
impossible, since any throw might have observable side effects.
I'm also confident that given enough time (perhaps not C++26, but
eventually) constexpr exception handling will be a thing. It's unclear
how that would work when there is global mutable state in the form of
a throw handler. Global mutable state doesn't really exist in constant
expressions.
It's irrelevant how quickly you could hack together something that
works in a specific implementation. This doesn't belong in the C++
standard.
Received on 2024-02-29 10:53:38