$ gcc -v Reading specs from /pdv/.tools/pkg/gcc/3.4.3/bin/../lib/gcc/powerpc-ibm- aix5.2.0.0/3.4.3/specs Configured with: ../gcc-3.4.3/configure --prefix=/tools/pkg/gcc/3.4.3 --with- ld=/bin/ld --with-as=/bin/as --disable-threads --enable-languages=c,c++ Thread model: aix gcc version 3.4.3
// foo.c // #include <stdio.h> inline void reverse( char* beg, char* end ) { while( beg < --end ) { char t = *end; *end = *beg; *beg++ = t; } } void doIt( int* val ) { reverse( (char*)val, (char*)val + sizeof( *val ) ); } int main() { int d = 0x12345678; printf( "%x\n", d ); doIt( &d ); printf( "%x\n", d ); return 0; } //// $ gcc -o foo foo.c -O2 $ foo 12345678 78345612 $ gcc -o foo foo.c $ foo 12345678 78563412 Works with GCC 3.3.3 -- Summary: wrong code with -O2 Product: gcc Version: 3.4.3 Status: UNCONFIRMED Severity: normal Priority: P2 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: joerg dot richter at pdv-fs dot de CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: powerpc-ibm-aix5.2.0.0 GCC host triplet: powerpc-ibm-aix5.2.0.0 GCC target triplet: powerpc-ibm-aix5.2.0.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21642