https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16070
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> --- Reduced: template<typename> struct basic_ios { }; template<typename T> basic_ios<T>& endl(basic_ios<T>& x) { return x; } template<typename T> void Bar(const T&) {} void Bar(int) {} int main() { Bar(endl); } GCC trunk says: 16070.cc: In function 'int main()': 16070.cc:9:13: error: no matching function for call to 'Bar(<unresolved overloaded function type>)' Bar(endl); ^ 16070.cc:5:9: note: candidate: 'template<class T> void Bar(const T&)' void Bar(const T&) {} ^~~ 16070.cc:5:9: note: template argument deduction/substitution failed: 16070.cc:9:13: note: couldn't deduce template parameter 'T' Bar(endl); ^ 16070.cc:6:9: note: candidate: 'void Bar(int)' void Bar(int) {} ^~~ 16070.cc:6:9: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int' Clang says: 16070.cc:9:5: error: no matching function for call to 'Bar' Bar(endl); ^~~ 16070.cc:6:9: note: candidate function not viable: no overload of 'endl' matching 'int' for 1st argument void Bar(int) {} ^ 16070.cc:5:9: note: candidate template ignored: couldn't infer template argument 'T' void Bar(const T&) {} ^ 1 error generated. EDG says: "16070.cc", line 9: error: no instance of overloaded function "Bar" matches the argument list argument types are: (<unknown-type>) Bar(endl); ^ 1 error detected in the compilation of "16070.cc". I don't think there's *much* room for improvement in GCC's output (but see below). (In reply to Ivan Godard from comment #4) > Hence what the compiler should produce is something like: > > Error: file crud line 234 > Cannot identify unique overload in call. Arguments are: > Foo(void (*)(int)) > Foo(void (*)(char)) > note: some arguments are overloaded functions; at least one of the overloads > must match in its argument position This isn't possible in your example, because endl is a function template, not just an overloaded function. That means the list of possible overloads is infinite, so you can't possible list all the overloads. There's only one function template, but an unbounded set of possible specializations of that function template that could be deduced in correct code. > overloads considered were: > file foo line 17: ..............; does not match because no possible > argument satisfied the template at argument position 1 > file bar line 23: ..............; does not match because no possible > argument satisfied the template at argument position 1 > file baz line 5: ..............; does not match because no argument 1 can > be coerced to type int This is pretty much what GCC does nowadays (and it can result in hundreds of lines of output, which has its own problems, but at least all the information is there for the user to inspect if they want to). One possible improvement I can imagine would be to special case some diagnostics to give a different message when there's an overload set involved. That seems to be what Clang does. Instead of: 16070.cc:6:9: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int' we could have a custom diagnostic for the <unresolved ...> case, like: 16070.cc:6:9: note: no overload of 'endl' can be converted to 'int' Personally I don't find this any clearer, but maybe people less used to GCC's errors would prefer it.