This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/26824] optimisation bug with -0x80000000
- From: "simonmar at microsoft dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Mar 2006 15:10:13 -0000
- Subject: [Bug c/26824] optimisation bug with -0x80000000
- References: <bug-26824-6341@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #5 from simonmar at microsoft dot com 2006-03-23 15:10 -------
I see your point, but I still think there's a bug. Let me change the code
slightly:
#include <stdlib.h>
#include <stdio.h>
void f(int x) {
long y;
if (x < 0) {
y = -x;
if (y > 0) {
printf("%d\n",y);
}
}
}
int main() {
f(-0x80000000);
exit(0);
}
$ gcc -O2 foo.c
$ ./a.out
-2147483648
so, we're in the y > 0 branch, but y is clearly < 0.
--
simonmar at microsoft dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Component|middle-end |c
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26824