* [Bug c++/31423] Improve upon "invalid use of member (did you forget the '&' ?)"
2007-04-01 22:01 [Bug c++/31423] New: Improve upon "invalid use of member (did you forget the '&' ?)" gerald at pfeifer dot com
@ 2007-04-02 16:09 ` bangerth at dealii dot org
2009-08-05 15:33 ` manu at gcc dot gnu dot org
` (6 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: bangerth at dealii dot org @ 2007-04-02 16:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from bangerth at dealii dot org 2007-04-02 17:09 -------
Confirmed.
W.
--
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bangerth at dealii dot org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2007-04-02 17:09:15
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31423
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/31423] Improve upon "invalid use of member (did you forget the '&' ?)"
2007-04-01 22:01 [Bug c++/31423] New: Improve upon "invalid use of member (did you forget the '&' ?)" gerald at pfeifer dot com
2007-04-02 16:09 ` [Bug c++/31423] " bangerth at dealii dot org
@ 2009-08-05 15:33 ` manu at gcc dot gnu dot org
2009-08-05 16:41 ` jwakely dot gcc at gmail dot com
` (5 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu dot org @ 2009-08-05 15:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from manu at gcc dot gnu dot org 2009-08-05 15:33 -------
Perhaps we could just mention both '&' and '()'? It seems a bit difficult to
check all the conditions that you mention.
BTW, shouldn't it say 'member function'? Can this be anything different than a
member function?
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2007-04-02 17:09:15 |2009-08-05 15:33:05
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31423
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/31423] Improve upon "invalid use of member (did you forget the '&' ?)"
2007-04-01 22:01 [Bug c++/31423] New: Improve upon "invalid use of member (did you forget the '&' ?)" gerald at pfeifer dot com
2007-04-02 16:09 ` [Bug c++/31423] " bangerth at dealii dot org
2009-08-05 15:33 ` manu at gcc dot gnu dot org
@ 2009-08-05 16:41 ` jwakely dot gcc at gmail dot com
2009-08-05 17:55 ` bangerth at gmail dot com
` (4 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: jwakely dot gcc at gmail dot com @ 2009-08-05 16:41 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from jwakely dot gcc at gmail dot com 2009-08-05 16:40 -------
&c.f isn't even valid, it should be &C::f
I didn't check the code, but that message isn't used for member variables or
nested types, so if it does only apply to member functions then I think
changing '&' to '()' unconditionally makes sense.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31423
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/31423] Improve upon "invalid use of member (did you forget the '&' ?)"
2007-04-01 22:01 [Bug c++/31423] New: Improve upon "invalid use of member (did you forget the '&' ?)" gerald at pfeifer dot com
` (2 preceding siblings ...)
2009-08-05 16:41 ` jwakely dot gcc at gmail dot com
@ 2009-08-05 17:55 ` bangerth at gmail dot com
2009-08-05 17:57 ` bangerth at gmail dot com
` (3 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: bangerth at gmail dot com @ 2009-08-05 17:55 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from bangerth at gmail dot com 2009-08-05 17:54 -------
(In reply to comment #3)
> &c.f isn't even valid, it should be &C::f
>
> I didn't check the code, but that message isn't used for member variables or
> nested types, so if it does only apply to member functions then I think
> changing '&' to '()' unconditionally makes sense.
It also strictly wouldn't make things worse: the message we currently print
hardly ever has anything to do with what is really happening, and replacing
the ampersand by parentheses can only make things better even if it isn't
always correct.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31423
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/31423] Improve upon "invalid use of member (did you forget the '&' ?)"
2007-04-01 22:01 [Bug c++/31423] New: Improve upon "invalid use of member (did you forget the '&' ?)" gerald at pfeifer dot com
` (3 preceding siblings ...)
2009-08-05 17:55 ` bangerth at gmail dot com
@ 2009-08-05 17:57 ` bangerth at gmail dot com
2009-08-05 18:19 ` manu at gcc dot gnu dot org
` (2 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: bangerth at gmail dot com @ 2009-08-05 17:57 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from bangerth at gmail dot com 2009-08-05 17:57 -------
However, one of my gripes with the previous error message is that it's
just too obscure: where did I forget the '&', and why would I have wanted
to write them in the first place? It could have said "did you forget to
take the address of this member function?" and it would have been clearer
to me what the message is supposed to tell me.
So, in order to be a bit less obscure, how about this wording:
6: error: invalid use of member (did you forget the argument list?)
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31423
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/31423] Improve upon "invalid use of member (did you forget the '&' ?)"
2007-04-01 22:01 [Bug c++/31423] New: Improve upon "invalid use of member (did you forget the '&' ?)" gerald at pfeifer dot com
` (4 preceding siblings ...)
2009-08-05 17:57 ` bangerth at gmail dot com
@ 2009-08-05 18:19 ` manu at gcc dot gnu dot org
2009-08-05 18:47 ` bangerth at gmail dot com
2009-08-06 9:51 ` jwakely dot gcc at gmail dot com
7 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu dot org @ 2009-08-05 18:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from manu at gcc dot gnu dot org 2009-08-05 18:19 -------
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
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/31423] Improve upon "invalid use of member (did you forget the '&' ?)"
2007-04-01 22:01 [Bug c++/31423] New: Improve upon "invalid use of member (did you forget the '&' ?)" gerald at pfeifer dot com
` (5 preceding siblings ...)
2009-08-05 18:19 ` manu at gcc dot gnu dot org
@ 2009-08-05 18:47 ` bangerth at gmail dot com
2009-08-06 9:51 ` jwakely dot gcc at gmail dot com
7 siblings, 0 replies; 12+ messages in thread
From: bangerth at gmail dot com @ 2009-08-05 18:47 UTC (permalink / raw)
To: gcc-bugs
------- 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/31423] Improve upon "invalid use of member (did you forget the '&' ?)"
2007-04-01 22:01 [Bug c++/31423] New: Improve upon "invalid use of member (did you forget the '&' ?)" gerald at pfeifer dot com
` (6 preceding siblings ...)
2009-08-05 18:47 ` bangerth at gmail dot com
@ 2009-08-06 9:51 ` jwakely dot gcc at gmail dot com
7 siblings, 0 replies; 12+ messages in thread
From: jwakely dot gcc at gmail dot com @ 2009-08-06 9:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from jwakely dot gcc at gmail dot com 2009-08-06 09:51 -------
I don't think any of those tests would be made correct simply by replacing 'f'
with '&f'
Maybe they would have been accepted by GCC 2.95 with the ampersand present, but
current GCC correctly requires '&C::f'
I know some users want the compiler to suggest how to fix their errors, but
it's hard to make a useful suggestion for most of the nearly infinite number of
invalid expressions users can come up with. The suggestion is misleading in
too many cases (specifically, the "did you forget the '&'?" hint doesn't solve
the problem in any of the examples given in this PR.)
--
jwakely dot gcc at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jwakely dot gcc at gmail dot
| |com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31423
^ permalink raw reply [flat|nested] 12+ messages in thread