This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/66601] New: RFE: improve diagnostics for failure to deduce template parameter pack that is not in the last position in the parameter list
- From: "avi at cloudius-systems dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 19 Jun 2015 17:08:58 +0000
- Subject: [Bug c++/66601] New: RFE: improve diagnostics for failure to deduce template parameter pack that is not in the last position in the parameter list
- Auto-submitted: auto-generated
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: avi@cloudius-systems.com
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.