------- Comment #2 from mikpe at it dot uu dot se 2009-05-31 08:10 ------- (In reply to comment #1) > The one compiled with O2 has wrong binary code. > > The problem occurs when GCC compiles the following lines with O2 flag. > > " > if (pdw && memcmp(a1, a2, pdw << 2)) > return 0; > " > > In the binary code, pdw is not shifted left by 2, which leads to wrong result.
I can confirm the test case breakage with gcc-4.1.2 on i686-pc-linux-gnu, however gcc-4.2.4 and gcc-4.3-20090524 work. Since both gcc-4.1 and gcc-4.2 are obsoleted and unsupported, you should consider upgrading to gcc-4.3 or gcc-4.4. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40312