https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111140
Bug ID: 111140
Summary: wrong error message
Product: gcc
Version: 12.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: [email protected]
Target Milestone: ---
% cat test.cpp
static void S__f (auto ...) { }
struct S
{
static void f (auto ...) { }
};
int main ()
{
S__f (1, { });
S::f (1, { });
}
% g++ -std=c++20 test.cpp
test.cpp: In function 'int main()':
test.cpp:10:8: error: too many arguments to function 'void S__f(auto:1 ...)
[with auto:1 = {}]'
10 | S__f (1, { });
| ~~~~~^~~~~~~~
test.cpp:1:13: note: declared here
1 | static void S__f (auto ...) { }
| ^~~~
test.cpp:11:8: error: no matching function for call to 'S::f(int,
<brace-enclosed initializer list>)'
11 | S::f (1, { });
| ~~~~~^~~~~~~~
test.cpp:5:15: note: candidate: 'static void S::f(auto:2 ...) [with auto:2 =
{}]'
5 | static void f (auto ...) { }
| ^
test.cpp:5:15: note: candidate expects 0 arguments, 2 provided
These error messages are just misleading. The functions accept any number of
arguments. The actual problem is that no type can be deduced for "{ }". (Of
course, it's easy to see here, but in more complex situations with multiple
overloads, it makes it really hard to understand what the problem is.)
Also strange: S__f and S::f are practically the same, yet the error message is
differently worded (though the meaning is very close).