https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87145
--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Slightly different testcase: struct S { int val; constexpr operator int() const { return static_cast<int>(val); } }; template<int N> struct F { }; template<unsigned N> constexpr void foo() { F<S{N}> f; } int main() { foo<2>(); }