Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardC++constexpr consteval constinitSingle-choice MCQ

A `consteval` function calls another ordinary `constexpr` function that, for some argument, would hit a non-constant operation (e.g. a runtime-only branch). What determines whether the whole program is ill-formed?

constexpr int f(int x) { if (x < 0) throw 1; // not allowed in a constant expression for x<0 return x * 2; } consteval int g(int x) { return f(x); } int main() { return g(-1); }