https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107065
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed| |2022-09-28 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- Reduced to remove the library dependency: enum Cat { prvalue, lvalue, xvalue }; template<typename T> struct value_category { // Or can be an integral or enum value static constexpr auto value = prvalue; }; template<typename T> struct value_category<T&> { static constexpr auto value = lvalue; }; template<typename T> struct value_category<T&&> { static constexpr auto value = xvalue; }; // Double parens for ensuring we inspect an expression, // not an entity #define VALUE_CATEGORY(expr) value_category<decltype((expr))>::value constexpr bool global = true; static_assert( VALUE_CATEGORY(!(!global)) == prvalue, "GCC gets this right" ); int main() { bool b = true; if ( VALUE_CATEGORY(!(!b)) != prvalue ) throw 1; }