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


3059. throw; in constant expressions

Section: 7.7  [expr.const]     Status: open     Submitter: Lénárd Szolnoki     Date: 2025-08-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: