Consider the following sample program:
struct S
{
int x;
int y;
};
int foo(int x, int y)
{
return x+y;
}
int foo(const S &s)
{
return s.x + s.y;
}
int foo2(int x)
{
foo(x);
}
When compiling this, clang prints:
#> clang ./tst.cc
./tst.cc:19:3: error: no matching function for call to 'foo'
foo(x);
^~~
./tst.cc:12:5: note: candidate function not viable: no known conversion from
'int' to 'struct S const' for 1st argument
int foo(const S &s)
^
./tst.cc:7:5: note: candidate function not viable: requires 2 arguments, but 1
was provided
int foo(int x, int y)
^
3 diagnostics generated.
Notice that each failed match is clearly explained. By comparison, gcc prints:
#> ./install/bin/gcc -c ./tst.cc
./tst.cc: In function int foo2(int):
./tst.cc:19:8: error: no matching function for call to foo(int&)
./tst.cc:7:5: note: candidates are: int foo(int, int)
./tst.cc:12:5: note: int foo(const S&)
In this case, it is easy to see what's going on. However, many C++ functions
contain multiple template arguments. In those cases, it can be difficult to
parse the diagnostics and understand what is wrong.
GCC should clearly indicate why each match failed.
--
Summary: When printing a list of candidate functions, explain why
each function failed to match.
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: aaw at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45329