The following code is compiled incorrectly with -O2: #include <stdlib.h>
void f(int x) { if (x < 0) { if (-x > 0) { exit(1); } } } int main() { f(-0x80000000); exit(0); } $ gcc foo.c; ./a.out $ gcc -O2 foo.c; ./a.out zsh: 4407 exit 1 ./a.out $ -- Summary: optimisation bug with -0x80000000 Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: major Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: simonmar at microsoft dot com GCC build triplet: x86_64-redhat-linux GCC host triplet: x86_64-redhat-linux GCC target triplet: x86_64-redhat-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26824