On ia64: gcc -O ~/bug.c On powerpc: gcc -O -m64 ~/bug.c The test case hits abort.
(This case came up when trying to compile GNU MP with gcc 4. I have yet to find a platform where gcc 4 works properly.) This is bug.c: #include <stdlib.h> int bar (void) { return -1; } unsigned long foo () { unsigned long retval; retval = bar (); if (retval == -1) return 0; return 3; } main () { if (foo () != 0) abort (); return 0; } -- Summary: Incorrect folding of comparison Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: critical Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: tege-gcc at swox dot com CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: ia64-redhat-linux, powerpc-apple-darwin8 GCC host triplet: ia64-redhat-linux, powerpc-apple-darwin8 GCC target triplet: ia64-redhat-linux, powerpc-apple-darwin8 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21331