[wwwdocs] Document Waddress in GCC 4.2

Gerald Pfeifer gerald@pfeifer.com
Sat Mar 31 23:25:00 GMT 2007


On Sat, 31 Mar 2007, Gabriel Dos Reis wrote:
>|   struct C {
>|     int f() { return 1; }
>|   };
>|
>|   int f(C &c) {
>|     return ( 1 == c.f );
>|   }
>|
>| we currently issue
>| 
>|   In function 'int f(C&)':
>|   6: error: invalid use of member (did you forget the '&' ?)
>| 
>| In such a case, that is, for member functions, isn't adding the missing
>| () more likely than adding &?  Would you like me to create a Bugzilla for
>| this?
> I'm not clear what you mean here; please could you elaborate?

Basically, my thought is that whenever we encounter a comparison of a 
member function c.f with a value that is compatible with its return type, 
the author of the code probably ment to write c.f() instead of &c.f, so
the error message could propose the former.

Specifically, I suggest to issue
  error: invalid use of member (did you forget the "()" ?)
instead of
  error: invalid use of member (did you forget the '&' ?)
when the return type of the function c.f is an integer type and we 
compare against an integer constant as per my original example.

Now, how hard this will be to implement, and whether there might be some 
challenges down the road, I don't know.  Just consider me a naive user who 
was a bit surprised by the error message in a real-life scenario. :-)

Gerald



More information about the Gcc-patches mailing list