wrong code generated in gcc3 (current cvs) for powerpc-eabi
Franz Sirl
Franz.Sirl-kernel@lauterbach.com
Wed Jul 4 02:57:00 GMT 2001
At 11:44 04.07.2001, Michael Schwingen wrote:
>Hello,
>
>using a fresh checkout of the gcc-3 branch, compiled as a cross-compiler for
>powerpc-eabi, I get wrong code in this case:
>
>
>unsigned short test3(unsigned int a)
>{
> unsigned short int *p = (unsigned short int *) &a;
> return p[0] ^ p[1] ^ 0x55;
>}
You violate the C aliasing rules, you cannot expect gcc to compile this
correctly. If you know you have code that doesn't conform to C standards in
this respect, pass -fno-strict-aliasing to gcc. Or, the better way, fixup
your code (eg. use a union here).
Franz.
More information about the Gcc-bugs
mailing list