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: unassig...@gcc.gnu.org ReportedBy: vlu...@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++.