https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90769
--- Comment #1 from Barry Revzin <barry.revzin at gmail dot com> --- Sorry, more reduced: #include <type_traits> enum E {A, B}; struct X { template <E f = B, std::enable_if_t<(f == B), int> = 0> constexpr X(int v); template <typename OUT, E f = B, std::enable_if_t<(f == B), int> = 0> operator OUT() const; }; #ifdef WORKS bool operator!=(X const& lhs, int) { return static_cast<int>(lhs) == 0; } #else bool operator==(X const& lhs, int) { return static_cast<int>(lhs) == 0; } #endif