This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: wrong code generated in gcc3 (current cvs) for powerpc-eabi
- To: Michael Schwingen <michaels at stochastik dot rwth-aachen dot de>
- Subject: Re: wrong code generated in gcc3 (current cvs) for powerpc-eabi
- From: Franz Sirl <Franz dot Sirl-kernel at lauterbach dot com>
- Date: Wed, 04 Jul 2001 11:57:18 +0200
- Cc: gcc-bugs at gcc dot gnu dot org
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.