Date: Mon, 4 Nov 2013 10:56:20 -0800
On Mon, Nov 4, 2013 at 10:42 AM, Gabriel Dos Reis <gdr_at_[hidden]> wrote:
> | -----Original Message-----
> | From: ub-bounces_at_[hidden] [mailto:ub-bounces_at_[hidden]] On
> Behalf Of
> | Lawrence Crowl
> | Sent: Monday, November 4, 2013 10:40 AM
> | To: WG21 UB study group
> | Subject: Re: [ub] bit_cast
> |
> | The intent is to provide an alternative to the idiom
> |
> | int i; float f = *(float*)&i;
> |
> | The usual objection is "but memcpy is slow".
> | The answer is "your compiler is better than you think".
>
> If we give it enough latitude in terms of non-aliasing :-)
The compiler needs no latitude to optimize using memcpy to do this.
> | -----Original Message-----
> | From: ub-bounces_at_[hidden] [mailto:ub-bounces_at_[hidden]] On
> Behalf Of
> | Lawrence Crowl
> | Sent: Monday, November 4, 2013 10:40 AM
> | To: WG21 UB study group
> | Subject: Re: [ub] bit_cast
> |
> | The intent is to provide an alternative to the idiom
> |
> | int i; float f = *(float*)&i;
> |
> | The usual objection is "but memcpy is slow".
> | The answer is "your compiler is better than you think".
>
> If we give it enough latitude in terms of non-aliasing :-)
The compiler needs no latitude to optimize using memcpy to do this.
Received on 2013-11-04 19:56:22