The following program: tcsh> cat bug.c #include <stdio.h> #include <stdlib.h> union u { unsigned i; struct { unsigned low : 16; unsigned high : 16; } s; }; static void cvt (unsigned *v) { union u u; u.i = *v; u.s.low = 3; memcpy (v, &u.i, sizeof (unsigned)); } int main () { unsigned i = 0x00010002; cvt (&i); printf ("res = %08x\n", i); return EXIT_SUCCESS; } Compiled on: tcsh> uname -a Linux hostname 2.2.12 #3 SMP Thu Sep 2 03:34:03 MDT 1999 i586 unknown Using cc: tcsh> cc --version egcs-2.91.66 With the command: tcsh> cc -O1 -o bug bug.c Produces the following result: tcsh> ./bug res = 00000003 I would prefer it to produce a "00010003" result.
At first glance this looks like the same bug as 5184 (also see http://people.redhat.com/kingdon/), which for reference concerns the "addressof" feature within GCC.
Fixed in the egcs currently in Raw Hide.