public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: gawrilow@math.tu-berlin.de To: gcc-gnats@gcc.gnu.org Subject: c++/3585: wrong function overload resolution? Date: Fri, 06 Jul 2001 04:06:00 -0000 [thread overview] Message-ID: <20010706110255.11783.qmail@sourceware.cygnus.com> (raw) >Number: 3585 >Category: c++ >Synopsis: wrong function overload resolution? >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Fri Jul 06 04:06:01 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Ewgenij Gawrilow >Release: 3.0 >Organization: >Environment: Sun UltraSPARC, Solaris 8 >Description: Let's consider the following fragment: void f(int& x) { } // #1 void f(int x) { } // #2 int temp() { return 0; } int main() { int var=0; f(var); // should resolve to #1 f(temp()); // resolves to #2 } The gcc rejects f(var) as ambiguous reasoning that #1 and #2 were equally good. IMHO, resolving to #2 includes an lvalue-to-rvalue conversion, where #1 incurs an identity conversion, thus being better. Am I missing something? The things become yet prettier as we move to templates. Let's change the definitions of f's to the following: template <class T> void f(T& x) { } // #1 template <class T> void f(T x) { } // #2 gcc 3.0 still considers this ambiguous, while 2.95 has chosen #1 for f(var) without any complains. Thus the final questions: who understands the overload resolution rules better: gcc 3.0, gcc 2.95, me (obviously not!), or somebody else? How could I otherwise distinct between rvalue and lvalue arguments to an overloaded function, without using f(const T&) ? Thanks in advance for any hint! >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2001-07-06 4:06 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2001-07-06 4:06 gawrilow [this message] 2001-07-06 6:51 gdr 2001-07-06 6:56 Gabriel Dos Reis 2001-07-06 9:56 Martin Sebor
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=20010706110255.11783.qmail@sourceware.cygnus.com \ --to=gawrilow@math.tu-berlin.de \ --cc=gcc-gnats@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: linkBe 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).