Bug#5367: gcc -O2 fails for INT_MIN < long long < INT_MAX
Package: gcc
Version: 2.7.2.1-1
A colleague of mine found that the gcc optimizer for ix86 fails for
long long a;
(a < MIN_INT || a > MAX_INT) : foo ? bar
You can reproduce the bug with the program at the end of the mail. This
bug was exploited while trying to use a cross-gdb for a 64-bit-processor
on Debian/Linux.
gcc 2.7.2-8 showed this bug too.
The bug was _not_ reproducable on a gcc 2.7.2.1 for
mips-mips-riscos4sysv, so it seem's to be limited on the ix86 optimizer.
Regards
Herbert.
Program to reproduce the bug (o.k. with -O0, buggy with -O1, -O2, -O3):
-snip-snap-snip-snap-
#include <stdio.h>
#include <limits.h>
#define LARGE 2000000000
#define CHECK_FALSE(expr) \
printf("%s: " #expr "\n", \
(expr) ? "BUG, assumed true" : \
"o.k., it is false")
void foo(long long val)
{
printf( "val=%Ld (%#Lx)\n"
"INT_MIN=%d (%#x)\n"
"INT_MAX=%d (%#x)\n"
"LARGE=%d (%#x)\n\n",
val, val, INT_MIN, INT_MIN, INT_MAX, INT_MAX, LARGE, LARGE);
CHECK_FALSE(val < INT_MIN);
CHECK_FALSE(val > INT_MAX);
CHECK_FALSE(val < INT_MIN || val > INT_MAX); /* Buggy with -O2 !! */
CHECK_FALSE(val < -LARGE || val > LARGE);
CHECK_FALSE(!(val > INT_MIN && val < INT_MAX));
return;
}
main()
{
long long a;
a = 5LL;
foo(a);
exit(0);
}
-snip-snap-snip-snap-
--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-devel-REQUEST@lists.debian.org . Trouble? e-mail to Bruce@Pixar.com
Reply to: