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

           Summary: Poor g++ suggestion: did you forget the ‘&’
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: i...@airs.com


If I compile this C++ test case with current mainline:

class C { public: C* f(); int get(); };
int f(C* p) { return p->f->get(); }

I get this:

foo.cc: In function ‘int f(C*)’:
foo.cc:2:26: error: invalid use of member (did you forget the ‘&’ ?)
foo.cc:2:26: error: base operand of ‘->’ is not a pointer

When I get this error message, it has never been the case that I forgot the
'&'.  It has always been the case that I forgot the '()', or that I typed a
method name where I meant to type a member name.  This particular suggestion
hurts more than it helps.

Some examination of context could probably produce a better suggestion. 
However, if that turns out to be too difficult, I think that overall we would
be better off if this particular suggestion were dropped.

Reply via email to