egcs 1.1.x union/aliasing bug (PPC)
Jeffrey A Law
law@upchuck.cygnus.com
Mon May 31 21:06:00 GMT 1999
In message < 199905191704.KAA11360@scv4.apple.com >you write:
> Hey there,
>
> There appears to be a problem with aliasing using egcs-1.1.1 PowerPC
> on an AIX box and egcs-1.1.2 on a MacOS X box.
>
> Compiling the following snippet with egcs-1.1.x -O2
>
> unsigned long bad(int reg, unsigned long inWord)
> {
> union {
> unsigned long word;
> unsigned char byte[4];
> } data;
>
> data.word = inWord;
> data.byte[reg] = 0;
>
> return data.word;
> }
>
> gives us:
>
> stw r4, -8(r1) <--- data.word = inWord
> addi r9, r1, -8 <--- create pointer to data
> li r0, 0
> stbx r0, r9, r3 <--- data.byte[reg] = 0
> mr r3, r4 <--- Oh dear. Should be "lwz r3, -8(r1)"
> blr
Thanks. I've fixed this bug and added a test to the regression testsuite.
jeff
More information about the Gcc-bugs
mailing list