This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
optimization bug in gcc-2.95
- To: gcc-bugs at gcc dot gnu dot org
- Subject: optimization bug in gcc-2.95
- From: Blair Kelly III <bfkelly at afterlife dot ncsc dot mil>
- Date: Thu, 19 Aug 1999 09:35:22 -0400 (EDT)
Kind gcc gurus,
Below is a demonstration of what I believe to be
an optimization bug in gcc-2.95. I would greatly
appreciate it if you could let me know if you can
duplicate this bug.
I just noticed that gcc-2.95.1 is now out. I have
NOT tried this possible bug yet on gcc-2.95.1.
Thanks,
Blair
*********************************************************************
/*
This C program demonstrates an optimazation bug in the
GNU gcc-2.95 compiler on a sparc running SunOS5.6.
: hades% uname -a
: SunOS hades 5.6 Generic_105181-07 sun4m sparc SUNW,SPARCstation-5
: hades% gcc -v
: Reading specs from
: /projects/r51/gcc/SunOS5.6-2.95/lib/gcc-lib/sparc-sun-solaris2.6/2.95/specs
: gcc version 2.95 19990728 (release)
: hades%
If compiled with two different optimization levels
gcc -O1 -o foo1 optbug.c
gcc -O2 -o foo2 optbug.c
foo1 returns the correct value of 100, while foo2 returns a garbage
value.
This bug does NOT appear under gcc-2.8.1.
bfkelly@afterlife.ncsc.mil
*/
#include <stdio.h>
main()
{
long p1;
double x = ((double) 10) * ((double) 10);
double t = x+(4503599627370496.0); /* 2^52 */
long *lo = (long *)&t;
p1 = lo[1];
printf("%d\n",p1);
}
*********************************************************************