https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121114
Bug ID: 121114
Summary: Decide how to deal with throwing exceptions during
constant evaluation
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
For C++26 we can throw and catch exceptions during constant evaluation, but our
current solution for throwing in e.g. std::vector is to call one of the
functions from <bits/functexcept.h> such as __throw_bad_alloc().
Those functions are not constexpr, and can't be because they're not inline.
Prior to C++26 that was fine, reaching a call to one of those functions would
cause constant evaluation to fail, which was exactly what we wanted. Now when
one of those conditions is reached, we need to throw at compile-time (but maybe
still abort at runtime).
We need to decide whether to change the __throw_xxx functions, or replace them
with constexpr functions that throw during consteval and call the old function
otherwise, or something else.
This is closely related to Bug 69388.