A peace of my code uses the two next macros (SWAP and InvSwap) to swap bytes, it worked for a long time under gcc-3.3 but not under gcc-4.0.3
under gcc-3.3: InvWord(0xABCD) = 0xCDAB under gcc-4-0.3: InvWord(0xABCD) = 0xCD00 !!!! ############ FILE STARTS HERE ################## #define SWAP(x,y) (x)^=(y)^=(x)^=(y) #define InvWord(x) SWAP(*((char *)(&(x))),*((char *)(&(x))+1)) int main() { unsigned short data_length; data_length = 0xABCD; InvWord(data_length); return 0; } ############ FILE ENDS HERE ################### I've also tried to use __bswap_16 but id did nothing :( thanks in advance -- Summary: byte swap incorrect Product: gcc Version: 4.0.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: behloul dot younes at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26923