public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/41575]  New: GCC lists private methods as candidates in "no matching function for call"
@ 2009-10-05 10:21 mnemo at minimum dot se
  2009-10-05 10:28 ` [Bug c++/41575] " redi at gcc dot gnu dot org
  2009-10-05 15:14 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: mnemo at minimum dot se @ 2009-10-05 10:21 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1656 bytes --]

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/41575] GCC lists private methods as candidates in "no matching function for call"
  2009-10-05 10:21 [Bug c++/41575] New: GCC lists private methods as candidates in "no matching function for call" mnemo at minimum dot se
@ 2009-10-05 10:28 ` redi at gcc dot gnu dot org
  2009-10-05 15:14 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu dot org @ 2009-10-05 10:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from redi at gcc dot gnu dot org  2009-10-05 10:28 -------
Access checking happens after overload resolution.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41575


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/41575] GCC lists private methods as candidates in "no matching function for call"
  2009-10-05 10:21 [Bug c++/41575] New: GCC lists private methods as candidates in "no matching function for call" mnemo at minimum dot se
  2009-10-05 10:28 ` [Bug c++/41575] " redi at gcc dot gnu dot org
@ 2009-10-05 15:14 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-10-05 15:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2009-10-05 15:14 -------
Namelookup is done before access control IIRC.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41575


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-10-05 15:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-05 10:21 [Bug c++/41575] New: GCC lists private methods as candidates in "no matching function for call" mnemo at minimum dot se
2009-10-05 10:28 ` [Bug c++/41575] " redi at gcc dot gnu dot org
2009-10-05 15:14 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).