https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92459
Bug ID: 92459 Summary: out of class method definition did not match (when declaration contains expression that uses in class defined enum) Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nok.raven at gmail dot com Target Milestone: --- template <bool> struct S {}; struct X { enum E { A }; template <X::E e> S<e==X::A>* foo(); }; template <X::E e> S<e==X::A>* X::foo() { return 0; } int main() { X().foo<X::A>(); } https://godbolt.org/z/YNUVzC When enum is defined outside of a class it compiles. --- template <bool> struct S {}; struct X { enum E { A }; template<E e> inline static constexpr bool q = A == e; template <E e> S<q<e>>* foo(); //S<X::q<e>>* foo(); // this one compiles }; template <X::E e> S<X::q<e>>* X::foo() { return 0; } int main() { X().foo<X::A>(); } https://godbolt.org/z/AvjYYr With this one Clang has problems too.