This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: wrong code generated in gcc3 (current cvs) for powerpc-eabi


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]