public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17459] New: Spurious message when forgetting parentheses on call of member
@ 2004-09-13 14:20 bangerth at dealii dot org
2004-09-13 17:33 ` [Bug c++/17459] " giovannibajo at libero dot it
2004-09-13 18:32 ` bangerth at dealii dot org
0 siblings, 2 replies; 3+ messages in thread
From: bangerth at dealii dot org @ 2004-09-13 14:20 UTC (permalink / raw)
To: gcc-bugs
(This is a spin-off from PR 17456)
Take this code:
-----------------
struct S {
void foo();
void bar() { foo; }
};
-----------------
Sure, the code looks odd: someone probably wanted to write foo() but
forgot the parentheses. But I would think it is valid: we take a reference
to the function S::foo and discard the result of this statement. But
we get an error from gcc instead:
g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -c x.cc
x.cc: In member function `void S::bar()':
x.cc:3: error: statement cannot resolve address of overloaded function
That strikes me as completely odd and wrong: first, I think there shouldn't
be an error in the first place; second, we certainly have no overloads
here, so the message's intent is completely puzzling to me. Note that
gcc2.95 printed this instead:
g/x> /home/bangerth/bin/gcc-2.*/bin/c++ -c x.cc
x.cc: In method `void S::bar()':
x.cc:3: invalid use of member (did you forget the `&' ?)
icc accepts the code without any warning or error.
No, for comparison, think of the case where the two functions are
non-members:
------------------
void foo();
void bar() { foo; }
------------------
Now we get
g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -c x.cc
x.cc: In function `void bar()':
x.cc:2: warning: statement is a reference, not call, to function `foo'
That makes more sense, and should have been what we get for the
member case as well.
W.
--
Summary: Spurious message when forgetting parentheses on call of
member
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bangerth at dealii dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17459
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/17459] Spurious message when forgetting parentheses on call of member
2004-09-13 14:20 [Bug c++/17459] New: Spurious message when forgetting parentheses on call of member bangerth at dealii dot org
@ 2004-09-13 17:33 ` giovannibajo at libero dot it
2004-09-13 18:32 ` bangerth at dealii dot org
1 sibling, 0 replies; 3+ messages in thread
From: giovannibajo at libero dot it @ 2004-09-13 17:33 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-09-13 17:33 -------
Notice that you need "&S::foo" to take the address of a member function. The
syntax "foo(blah)" is the function call syntax, and it is available only for
function calls.
I am not sure why EDG accepts it. Anyway, our diagnostic is suboptimal.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17459
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/17459] Spurious message when forgetting parentheses on call of member
2004-09-13 14:20 [Bug c++/17459] New: Spurious message when forgetting parentheses on call of member bangerth at dealii dot org
2004-09-13 17:33 ` [Bug c++/17459] " giovannibajo at libero dot it
@ 2004-09-13 18:32 ` bangerth at dealii dot org
1 sibling, 0 replies; 3+ messages in thread
From: bangerth at dealii dot org @ 2004-09-13 18:32 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-09-13 18:32 -------
Uhm, yes... I tend to take icc's acceptance as standards conformance
sometimes :-(
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2004-09-13 18:32:41
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17459
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-09-13 18:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-13 14:20 [Bug c++/17459] New: Spurious message when forgetting parentheses on call of member bangerth at dealii dot org
2004-09-13 17:33 ` [Bug c++/17459] " giovannibajo at libero dot it
2004-09-13 18:32 ` bangerth at dealii dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).