
9 Sep
2011
9 Sep
'11
8:29 a.m.
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.