This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/31423] New: Improve upon "invalid use of member (did you forget the '&' ?)"


For the program

   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 '&' ?)

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.


-- 
           Summary: Improve upon "invalid use of member (did you forget the
                    '&' ?)"
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gerald at pfeifer dot com


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]