Boost logo

Boost :

Subject: Re: [boost] [Endian] Performance
From: John Filo (filo_at_[hidden])
Date: 2011-09-09 08:53:30


On 09/09/2011 03:29 AM, Mathias Gaunard wrote:
> 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.

I wondered about that; I assumed that since the return statement was the
only memory read from memory in the function, and that there were no
writes that aliasing wouldn't be a problem. Also, I had -Wall on and
GCC didn't complain, so I assumed it was okay. I guess I need to read up
on what the exact rules are.


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