This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 118b. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-09-28
(From submission #756.)
Consider:
int main() {
try {
throw 0;
} catch (...) {
constexpr int x = [] {
try {
throw; // #1
} catch (...)
return 1;
}
}();
}
}
According to 7.6.18 [expr.throw] paragraph 3, #1 rethrows the currently handled exception as defined in 14.4 [except.handle] paragraph 10, which would rethrow the runtime exception inside a constant expression.
Suggested resolution:
Add a new bullet after 7.7 [expr.const] bullet 10.22 as follows:
- ...
- a construction of an exception object, unless the exception object and all of its implicit copies created by invocations of std::current_exception or std::rethrow_exception (17.9.7 [propagation]) are destroyed within the evaluation of E;
- a throw-expression (7.6.18 [expr.throw]) with no operand, unless there is a currently handled exception whose exception object was constructed within the evaluation of E;
- ...