From: johanknol Date: Tue, 18 Feb 2003 09:54:30 +0000 (+0000) Subject: bad shift right 12 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=2f6182c2e008dfe9d1ce2f4c3037b2638021f4db;p=fw%2Fsdcc bad shift right 12 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2280 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/support/regression/tests/bug-607243.c b/support/regression/tests/bug-607243.c new file mode 100644 index 00000000..00ed648d --- /dev/null +++ b/support/regression/tests/bug-607243.c @@ -0,0 +1,16 @@ +/* bad shift right 12 */ + +#include + +typedef unsigned int u16_t; + +struct myhdr { u16_t x; } h, *p; + +#define NTOHS(n) (((((u16_t)(n) & 0xff)) << 8) | (((u16_t)(n) & 0xff00) >> 8)) +#define IPH_V(hdr) ((u16_t)NTOHS((hdr)->x) >> 12) + +void foo(void) { + p = &h; + p->x = 0x45; + ASSERT(IPH_V(p)==4); +}