[Bug c++/41575] New: GCC lists private methods as candidates in "no matching function for call"
mnemo at minimum dot se
gcc-bugzilla@gcc.gnu.org
Mon Oct 5 10:21:00 GMT 2009
The following C++ code:
########################################
class Klass
{
public:
private:
static void f(const char*& a, int b) {}
};
int main (void)
{
char* x;
Klass::f (x);
}
########################################
Incorrectly produces the follow error message in GCC:
main.cpp: In function Âint main()Â:
main.cpp:13: error: no matching function for call to ÂKlass::f(char*&)Â
main.cpp:7: note: candidates are: static void Klass::f(const char*&, int)
This is not correct because f() is not a valid candidate because it's private
and can never be called from outside of Klass.
The purpose of this error message is to help the end user understand why his
function call is not accepted by GCC (usually it's because one of the types are
wrong in the parameter list, which is why the provided and candidate parameters
are printed in the first place). However, in this context the fact that f is
private is also highly relevant.
Basically this is very confusing, GCC should mention that the only candidate is
private and that's why stuff won't compile. Alternatively, GCC should not claim
that f() is a candidate at all, because in reality it's not a candidate because
it's not callable.
--
Summary: GCC lists private methods as candidates in "no matching
function for call"
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mnemo at minimum dot se
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41575
More information about the Gcc-bugs
mailing list