This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: question on template overload
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Graziano Servizi <Graziano dot Servizi at bo dot infn dot it>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Fri, 21 Nov 2014 16:33:25 +0000
- Subject: Re: question on template overload
- Authentication-results: sourceware.org; auth=none
- References: <546F4B3F dot 3060901 at bo dot infn dot it>
On 21 November 2014 14:25, Graziano Servizi <Graziano.Servizi@bo.infn.it> wrote:
> Hi, everybody
>
> I have already looked for an answer to my question on stackoverflow, finding
> this
>
> http://stackoverflow.com/questions/13649061/manual-select-overloaded-function-for-rvalue-or-lvalue-type
>
> 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;
> f(x);
> f(0.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
> does?
It's a bug, it works in GCC 4.9