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] Improve upon "invalid use of member (did you forget the '&' ?)"



------- Comment #7 from bangerth at gmail dot com  2009-08-05 18:47 -------
(In reply to comment #6)
> Examples where the ampersand probably makes more sense are:
> 
> g++.dg/rtti/typeid8.C
> g++.dg/conversion/memfn2.C
> g++.old-deja/g++.other/asm2.C

Possibly, but in all those cases, it may also have been a
call expression:
- in typeid8.C, did the user mean
    typeid (&A::foo).name ();
  or
    typeid (A::foo()).name ();
  (assuming A::foo is static)? Certainly in the case
    typeid (foo).name ();
  it is more likely that she wanted to say foo() than &A::foo.

- in memfn2.C, 
    void (*p)() = i ? foo : foo
  was more likely meant to say
    void (*p)() = i ? foo() : foo()
  than
    void (*p)() = i ? &A::foo : &A::foo

All I really mean is that it's at the very least equally likely
that people forget the parentheses than the ampersand. Just as
another argument, people *call* functions much more often than
they *take the address* of them -- so, all things being equal,
it's probably more likely that in any given context the intent
was a call, rather than taking the address.

W.

> 
> Not so sure about:
> 
> g++.dg/template/pseudodtor3.C
> g++.dg/template/using14.C
> 
> So this is not as trivial.
> 


-- 


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]