http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57678
Bug ID: 57678 Summary: too many errors for bad template parameter Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: manu at gcc dot gnu.org template<int N> int foo(int a) { return N; } void bar(void) { foo<x>(5); } triggers: test.cpp:5:9: error: ‘x’ was not declared in this scope foo<x>(5); ^ test.cpp:5:13: error: no matching function for call to ‘foo(int)’ foo<x>(5); ^ test.cpp:5:13: note: candidate is: test.cpp:1:21: note: template<int N> int foo(int) template<int N> int foo(int a) { return N; } ^ test.cpp:1:21: note: template argument deduction/substitution failed: test.cpp:5:13: error: template argument 1 is invalid foo<x>(5); ^ The second error is not useful (and the last "error" should be a note), why even try to match the function call if the template argument was invalid? Is there any case where the template argument is invalid and the invalidity is not triggered by a previous error? Clang: test.cpp:5:9: error: use of undeclared identifier 'x' foo<x>(5); ^