[Bug c++/41575] GCC lists private methods as candidates in "no matching function for call"
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Feb 7 19:06:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41575
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|UNCONFIRMED |NEW
Last reconfirmed| |2017-02-07
CC| |msebor at gcc dot gnu.org
Ever confirmed|0 |1
Severity|normal |enhancement
--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
As stated in the comments the error message is strictly correct because
overload resolution takes place before access checking. At the same time, I do
agree that it might be helpful to mention the access level of each candidate in
the error message if/when the access matters, similarly to what Clang does
(below). On that basis I'll confirm this as an enhancement request.
t.C:11:16: error: 'f' is a private member of 'Klass'
Klass::f (x);
^
t.C:5:21: note: declared private here
static void f(const char*& a, int b) {}
^
t.C:11:20: error: too few arguments to function call, expected 2, have 1
Klass::f (x);
~~~~~~~~ ^
t.C:5:9: note: 'f' declared here
static void f(const char*& a, int b) {}
More information about the Gcc-bugs
mailing list