question on template overload

Graziano Servizi
Fri Nov 21 14:24:00 GMT 2014

Hi, everybody

I have already looked for an answer to my question on stackoverflow, 
finding this

and also looked among the known gcc bugs (without finding something 
useful); I have also read the standard as carefully as I can...

so the question is:

are known reasons leading the following silly code

template <typename Z> void f(Z& z) {}
template <typename Z> void f(Z&& z) {}

int main()
   double x = 0;

not being compiled by gcc 4.8.3 (without a const qualifier
in the lvalue-reference parameter of the first overload) while clang 3.4 

The diagnostic says that the first function call is ambiguous:
what about partial ordering? By the way clang resolves the two function 
calls by calling the first and second overload respectively.

In stackoverflow it is said that this code is C++11 standard compliant...

Thanks for your attention.

                         G. Servizi

More information about the Gcc-help mailing list