public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/17459] New: Spurious message when forgetting parentheses on call of member
Date: Mon, 13 Sep 2004 14:20:00 -0000	[thread overview]
Message-ID: <20040913141957.17459.bangerth@dealii.org> (raw)

(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


             reply	other threads:[~2004-09-13 14:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-13 14:20 bangerth at dealii dot org [this message]
2004-09-13 17:33 ` [Bug c++/17459] " giovannibajo at libero dot it
2004-09-13 18:32 ` bangerth at dealii dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040913141957.17459.bangerth@dealii.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).