Hi, The following code is undefined behavior in C++17. And undefined behavior is not allowed in constant expressions - the compiler is required to diagnose it. Adapted from cppreference: enum foo { a = 0, b = 1 }; constexpr foo x = static_cast<foo>(123); // undefined behavior since C++17 However Clang happily compiles this code: https://godbolt.org/z/bzhWMxqoE
Confirmed; it doesn't look like any major compiler diagnoses this.
Yep: https://stackoverflow.com/a/66723431 There's an open bug for GCC: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95701