This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/31423] Improve upon "invalid use of member (did you forget the '&' ?)"
- From: "bangerth at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Aug 2009 18:47:00 -0000
- Subject: [Bug c++/31423] Improve upon "invalid use of member (did you forget the '&' ?)"
- References: <bug-31423-231@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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