public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "vlukas at gmx dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/53497] New: Partial ordering of function templates does not order lvalue/rvalue references correctly
Date: Sun, 27 May 2012 12:00:00 -0000	[thread overview]
Message-ID: <bug-53497-4@http.gcc.gnu.org/bugzilla/> (raw)

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53497

             Bug #: 53497
           Summary: Partial ordering of function templates does not order
                    lvalue/rvalue references correctly
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: vlukas@gmx.de


Following defect report 1164
(http://open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#1164) a rule was
added to partial ordering of function templates, so that parameters declared as
lvalue-references are considered more specialized than those declared as
rvalue-references. GCC does not implement this, i.e.
-----------------------------------------------
template<typename T>
void t(T&);
template<typename T>
void t(T&&);

int x;
void f() {
  t(x);
}
-----------------------------------------------
is rejected by GCC 4.7.0 and a 4.8.0 prerelease. Diagnostic for the latter is:
---------------------------------------------------------------------
c++ -std=c++11 -c ref_binding.cc
ref_binding.cc: In function ‘void f()’:
ref_binding.cc:8:6: error: call of overloaded ‘t(int&)’ is ambiguous
   t(x);
      ^
ref_binding.cc:8:6: note: candidates are:
ref_binding.cc:2:6: note: void t(T&) [with T = int]
 void t(T&);
      ^
ref_binding.cc:4:6: note: void t(T&&) [with T = int&]
 void t(T&&);
      ^
---------------------------------------------------------------------

Full compiler identification:
---------------------------------------------------------------------
c++ -v
Using built-in specs.
COLLECT_GCC=/home/lima/vanilla_installs/gcc_and_tools/bin/c++
COLLECT_LTO_WRAPPER=/home/lima/vanilla_installs/gcc_and_tools/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc_svn/configure
--prefix=/home/lima/vanilla_installs/gcc_and_tools --enable-threads
--enable-__cxa_atexit --enable-languages=c,c++
--enable-version-specific-runtime-libs --disable-multilib
Thread model: posix
gcc version 4.8.0 20120526 (experimental) (GCC)
--------------------------------------------------------------------

DR 1164 appears to have made it into the standard, it is marked FDIS and I find
it in both the N3290 and N3376 drafts of C++.


             reply	other threads:[~2012-05-27 11:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-27 12:00 vlukas at gmx dot de [this message]
2013-05-05  9:53 ` [Bug c++/53497] " paolo.carlini at oracle dot com

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=bug-53497-4@http.gcc.gnu.org/bugzilla/ \
    --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).