------- Comment #10 from mikpe at it dot uu dot se 2009-12-31 17:01 ------- Created an attachment (id=19431) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19431&action=view) simpler test case
I'm attaching a reduced test case that triggers wrong-code for m68k-elf with gcc-4.5-20091224, every 4.x release, and 3.4.6 (didn't check older releases). To trigger, compile with -O2 (or higher) and -m68020 (or higher), and observe how bar() skips all tests and just returns zero. Any of the following actions mask the bug: 1. reduce optimization level to -O1 2. reduce target cpu type to -m68010 or -m68000 3. remove the "__attribute__((packed))" from "union foo" 4. in bar(), replace "p->d[0]" with "p->d[1]" so that the first and second memory accesses don't have the same base address -fno-strict-aliasing makes no difference -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42522