https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66601
Bug ID: 66601
Summary: RFE: improve diagnostics for failure to deduce
template parameter pack that is not in the last
position in the parameter list
Product: gcc
Version: 5.1.1
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: [email protected]
Target Milestone: ---
Given the source
template <typename... X, typename Y>
void f(X... x, Y y) {
}
int main(int ac, char** av) {
f(1, 2, 3, 4);
return 0;
}
gcc (correctly) fails to deduce X as int, int, int.
However, the diagnostic is not very helpful:
./variadic-function-nonlast.cc: In function ‘int main(int, char**)’:
./variadic-function-nonlast.cc:9:15: error: no matching function for call to
‘f(int, int, int, int)’
f(1, 2, 3, 4);
^
./variadic-function-nonlast.cc:4:6: note: candidate: template<class ... X,
class Y> void f(X ..., Y)
void f(X... x, Y y) {
^
./variadic-function-nonlast.cc:4:6: note: template argument
deduction/substitution failed:
./variadic-function-nonlast.cc:9:15: note: candidate expects 1 argument, 4
provided
f(1, 2, 3, 4);
The user cannot understand from this why gcc is refusing to to deduce X, or
that explicitly specifying it (f<int, int, int>(1, 2, 3, 4)) would work.
If gcc would add an additional note:
./variadic-function-nonlast.cc:9:15: note: parameter pack 'X' in non-last
position not specified; deduced as empty parameter pack
then the user would understand exactly what happened here, and how to rectify
it.
The error message from clang 3.5 are not particularly helpful.