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



             Bug #: 57172

           Summary: [C++11][DR 1164] Template overload resolution

                    ambiguous for T&& versus T&

    Classification: Unclassified

           Product: gcc

           Version: 4.9.0

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: c++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: daniel.krueg...@googlemail.com





The following code is rejected by gcc 4.9.0 20130428 (experimental) using the

compiler flags



-std=c++11 -Wall -pedantic-errors



//-----------------------------

template<typename T> int f(T&){}

template<typename T> int f(T&&);

int i;

int j = f(i);

//-----------------------------



"main.cpp|4|error: call of overloaded 'f(int&)' is ambiguous|

 main.cpp|4|note: candidates are:|

 main.cpp|1|note: int f(T&) [with T = int]|

 main.cpp|2|note: int f(T&&) [with T = int&]|"



This example was relevant for



http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1164



and the core language has been adapted to make it well-formed as described by

[temp.deduct.partial] p9 b1. The compiler should select the first overload

here.

Reply via email to