A simple byte swap routine gets the wrong result when compiled with -m64 and
either -O1, -O2, -O3 or -Os.
[EMAIL PROTECTED]:~> /opt/biarch/gcc41-base/bin/gcc -O1 -m64 badswap.c
[EMAIL PROTECTED]:~> ./a.out
Before: 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88
Result: 0x88 0x77 0x66 0x55 0x44 0x77 0x22 0x11
Expected: 0x88 0x77 0x66 0x55 0x44 0x33 0x22 0x11
Notice the third to last byte in "Result" is 0x77 when it should be 0x33. This
works with -O0 and with gcc 3.4 or earlier versions.
--
Summary: Wrong result after swap byte in one word when compiled
in 64-bit mode
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: regression
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bergner at vnet dot ibm dot com
GCC build triplet: powerpc64-linux
GCC host triplet: powerpc64-linux
GCC target triplet: powerpc64-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28170