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

--- Comment #5 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Paolo Carlini from comment #4)
> Manuel can you help me reassessing this? I think we are doing much better.

I get this:

test.cc:3:19: error: invalid use of non-static member function
   void bar() { foo; } 
                   ^
 void S::bar3()
test.cc:5:18: error: ISO C++ forbids taking the address of an unqualified or
parenthesized non-static member function to form a pointer to member function. 
Say ‘&S::foo’ [-fpermissive]
   void bar3() { &foo; } 
                  ^
 void* S::bar2()
test.cc:6:26: error: cannot convert ‘S::foo’ from type ‘void (S::)()’ to type
‘void*’
   void * bar2() { return foo; }
                          ^

The first error could be a bit nicer if it said why it is invalid. Clang does:

test.cc:3:16: error: reference to non-static member function must be called;
did you mean to call it with no arguments?

but the thing is that this is not even a valid reference, so the error could
clarify a bit more the problem, no?

ISO C++ forbids taking the address of an unqualified non-static member
function, say ‘&S::foo’ instead; or did you mean to call 'foo()'?

The last error is bogus, it should be the same as the first one. Clang gives
two errors, but at least the first is the correct one:

test.cc:6:26: error: reference to non-static member function must be called;
did you mean to call it with no arguments?
  void * bar2() { return foo; }
                         ^~~
                            ()
test.cc:6:26: error: cannot initialize return object of type 'void *' with an
rvalue of type 'void'
  void * bar2() { return foo; }
                         ^~~~

Reply via email to