https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119451
Bug ID: 119451 Summary: Erroneous 'ambiguous template specialization' for overloaded template function in explicit instantiation Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rush102333 at gmail dot com Target Milestone: --- The following code is rejected by GCC, but accepted by clang, MSVC and EDG: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ template <class T> struct A { void f(T) {} template <typename MUT> void f(MUT t){} }; template void A<int>::f(int); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ https://godbolt.org/z/6P3Y8zxhE I'm not sure but the other compilers seem always to choose the non-template member function, while gcc complains about ambiguous names: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <source>:16:6: error: ambiguous template specialization 'f<>' for 'void A<int>::f(int)' 16 | void A<int>::f(int); | ^~~~~~ <source>:4:10: note: candidates are: 'void A<T>::f(T) [with T = int]' 4 | void f(T) {} | ^ <source>:5:34: note: 'template<class MUT> void A<T>::f(MUT) [with T = int]' 5 | template <typename MUT> void f(MUT t){} | ^ Compiler returned: 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~