meyering@CS.UTEXAS.EDU (03/19/89)
gcc-1.34 (with -W patches posted by Paul Hudson)
config.gcc sun4-os4
Sun4/280 OS 4.0
The program below generates the output "1.0000002381857"
The correct result is simply "1" -- Any one of several minor
modifications to the code will cause it to give the correct result:
1) remove the statement that assigns to y[i]
2) make "x[i]" a scalar
3) remove for-loop, and set i=0
main()
{
double x[2],y[2];
int i;
for (i=0; i<1; i++) {
x[i] = 1.0e0;
printf("%.14g\n", x[i]);
y[i] = 2.0e0;
}
}
Jim Meyering meyering@cs.utexas.edumeyering@CS.UTEXAS.EDU (03/20/89)
I recently reported what appears to be a bug in gcc-1.34 where a double is mistakenly truncated to single-precision. I didn't mention that this behavior occurs only when optimizing. % gcc -v -O dbl-flt.c -o dbl-flt gcc version 1.34 /p/lib/gcc-1.34/gcc-cpp -v -undef -D__GNUC__ -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__OPTIMIZE__ dbl-flt.c /tmp/cca00592.cpp GNU CPP version 1.34 /p/lib/gcc-1.34/gcc-cc1 /tmp/cca00592.cpp -quiet -dumpbase dbl-flt.c -O -version -o /tmp/cca00592.s GNU C version 1.34 (sparc) compiled by GNU C version 1.34. as /tmp/cca00592.s -o dbl-flt.o ld -o dbl-flt -e start -dc -dp /lib/crt0.o dbl-flt.o /p/lib/gcc-1.34/gcc-gnulib -lc Jim Meyering meyering@cs.utexas.edu