https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99186
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|diagnostic | --- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> --- Reduced to remove the library dependency: template<int N, typename T, typename... U> struct tuple_impl : tuple_impl<N + 1, U...> { }; template<int N, typename T> struct tuple_impl<N, T> { }; template<typename T, typename U> struct tuple : tuple_impl<0, T, U> { }; template<typename T, int N, typename... U> void get(const tuple_impl<N, T, U...>&) { } enum class E1 {a}; enum class E2 {b,c}; template < auto > struct S { int i; }; int main() { tuple<S<E1::a>,S<E2::b>> x; get<S<E2::b>>(x); // does not compile } Clang and EDG compile this, G++ has a bogus ambiguity: ambig.C: In function ‘int main()’: ambig.C:28:18: error: invalid initialization of reference of type ‘const tuple_impl<0, S<E2::b>, S<E2::b> >&’ from expression of type ‘tuple<S<E1::a>, S<E2::b> >’ 28 | get<S<E2::b>>(x); // does not compile | ^ ambig.C:13:5: note: in passing argument 1 of ‘void get(const tuple_impl<N, T, U ...>&) [with T = S<E2::b>; int N = 0; U = {S<E2::b>}]’ 13 | get(const tuple_impl<N, T, U...>&) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The bug is that S<E1::a> and S<E2::b> are distinct types but the compiler gets them confuses. We have several bugs about template<auto> types that get confused.