https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66968
Bug ID: 66968 Summary: Incorrect template argument shown in diagnostic Product: gcc Version: 6.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- Compiling this invalid code produces an error as expected: template<typename T> struct thing { }; template<typename T, typename XXX> bool operator==(const thing<T>&, const thing<XXX>&); struct nested { typedef int name; }; template<typename A, typename B> void func(typename A::name const&, const B) { } template<typename A, typename B> void func(typename A::name const&, const thing<B>) { } int main() { thing<int> ti; func<nested>(1, ti); } However the error has an error: y.cc: In function ‘int main()’: y.cc:17:21: error: call of overloaded ‘func(int, thing<int>&)’ is ambiguous func<nested>(1, ti); ^ y.cc:9:6: note: candidate: void func(const typename A::name&, B) [with A = nested; B = thing<int>; typename A::name = int] void func(typename A::name const&, const B) { } ^ y.cc:12:6: note: candidate: void func(const typename A::name&, thing<XXX>) [with A = nested; B = int; typename A::name = int] void func(typename A::name const&, const thing<B>) { } ^ Note that the second candidate shows thing<XXX>, where does that XXX come from?! The "[with ...]" output correctly shows the template parameter B but B doesn't appear in the candidate. For some reason XXX is shown instead, which is only ever mentioned in the operator== declaration above, which is never used!