Messages in this thread | | | Date | Thu, 17 Jun 1999 17:15:49 +0800 (CST) | From | dinon <> | Subject | egcs-1.1.2 ping bug also causes miscompilation of pcbit isdn driver |
| |
On Wed, 16 Jun 1999 owner-linux-kernel-digest@vger.rutgers.edu wrote: > > On 13 Jun 1999 16:47:26 +0200, Lars Heete wrote: > > >Hello, > > > >the bug in egcs-1.1.2 that causes miscompilations of in_cksum also is > >responsible for the pcbit-isdn driver failure (See thread "Still no ISDN > >connection"). I suspect there are some other places in kernel > >which suffer from this bug. > > > >--------------------- test case ---------------------- > >#include <stdio.h> > >int main(int argc, char **argv) { > > struct {char c1, c2, c2, 4;} t; > > t.c4 = 0x78; t.c3 = 0x56; t.c2 = 0x34; t.c1 = 0x12; > > printf("0x%x\n", *((unsigned long*) &t)); > > return 0; > >} > > > >gives 0x12 with egcs-1.1.2 on i386, instead of 0x78563412. > >
try the modifier volatile
#include <stdio.h>
#ifdef USE_VOLATILE #define VOLATILE volatile #else #define VOLATILE #endif
int main(int argc, char **argv) { VOLATILE struct {char c1, c2, c3, c4;} t; t.c4 = 0x78; t.c3 = 0x56; t.c2 = 0x34; t.c1 = 0x12; printf("0x%x\n", *((unsigned long*) &t)); return 0; }
if USE_VOLATILE is defined, then the result will be 0x78563412, otherwise 0x12, whether -fstrict-aliasing is used. So, I think maybe egcs over-optimizes in this case.
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |