Boost logo

Boost :

Subject: Re: [boost] [Endian] Performance
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2011-09-09 04:29:46


On 07/09/2011 14:16, John Filo wrote:

> I.e. I added:
>
> #elif USE_BIG
> return *reinterpret_cast<const ubig32_t*>(&src);
> #elif USE_LITTLE
> return *reinterpret_cast<const ulittle32_t*>(&src);
> #elif USE_NATIVE
> return src;

This breaks aliasing rules.

> and on a Intel Core2 with gcc-4.4.3, I get the following results at
> -O2 (except where noted, -O3 and -O4 produced nearly identical
> results):

GCC is one of the few compilers that follow aliasing rules.
There is no guarantee that the code generated is correct.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk