This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/26923] New: byte swap incorrect
- From: "behloul dot younes at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Mar 2006 16:34:50 -0000
- Subject: [Bug c/26923] New: byte swap incorrect
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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