This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/41575] New: GCC lists private methods as candidates in "no matching function for call"
- From: "mnemo at minimum dot se" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Oct 2009 10:20:49 -0000
- Subject: [Bug c++/41575] New: GCC lists private methods as candidates in "no matching function for call"
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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