[Linux-ia64] gcc bug

From: David Mosberger <davidm_at_hpl.hp.com>
Date: 2001-01-26 19:09:55
The attached program demonstrates a gcc code generation bug.  I'm
seeing this bug with the November snapshot with all patches applied.
Specifically, if I compile the program with "-O", it works fine and I
get:

	$ gcc -O t.c
	$ ./a.out 
	feed0000beef

However, if I compile it with "-O2", I get:

	$ gcc -O2 t.c
	$ ./a.out
	beef

which obviously can't be right.

	--david

struct f {
  unsigned long lo : 32;
  unsigned long hi : 32;
};

unsigned long r;

void
doit (unsigned long value1, unsigned long value2)
{
  unsigned long w, t;

  ((struct f*)&w)->lo = ((struct f*)&value1)->lo;
  ((struct f*)&w)->hi = ((struct f*)&value2)->hi;
  r = w;
}

int
main (int argc, char **argv)
{
  doit(0xbeef, 0xfeed00000000);
  printf ("%lx\n", r);
}
Received on Fri Jan 26 00:10:06 2001

This archive was generated by hypermail 2.1.8 : 2005-08-02 09:20:01 EST