Article View: gnu.gcc.bug
Article #332Re: IEEE zero problem
From: Paul Eggert
Date: Tue, 11 Aug 1992 05:14
Date: Tue, 11 Aug 1992 05:14
25 lines
1755 bytes
1755 bytes
About Peter Miller's bug report, I wrote ``GCC is acting correctly in
the cases that you cite.'' I was right about one case, but wrong about
the other -- there is a bug in GCC 2.2.2 (sparc, SunOS 4.1.2). Here's
a simple test case that illustrates it:
Program:
double normalize(x) double x; { if (x == 0) x = 0; return x; }
main() { printf("%g\n", normalize(-0.0)); }
Transcript:
$ gcc -O -v t.c
Reading specs from /reb0.1/sun4c-4.1.2/lib/gcc-lib/sparc-sun/2.2.2/specs
gcc version 2.2.2
/reb0.1/sun4c-4.1.2/lib/gcc-lib/sparc-sun/2.2.2/cpp -lang-c -v -undef -D__GNUC__=2 -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix -D__OPTIMIZE__ t.c /usr/tmp/cca24499.i
GNU CPP version 2.2.2 (sparc)
/reb0.1/sun4c-4.1.2/lib/gcc-lib/sparc-sun/2.2.2/cc1 /usr/tmp/cca24499.i -quiet -dumpbase t.c -O -version -o /usr/tmp/cca24499.s
GNU C version 2.2.2 (sparc) compiled by GNU C version 2.2.2.
as -o t.o /usr/tmp/cca24499.s
/reb0.1/sun4c-4.1.2/lib/gcc-lib/sparc-sun/2.2.2/ld -e start -dc -dp /lib/crt0.o -L/reb0.1/sun4c-4.1.2/lib/gcc-lib/sparc-sun/2.2.2 -L/reb0.1/sun4c-4.1.2/lib t.o -lgcc -lc -lgcc
$ ./a.out
-0
The output should be `0', not `-0'. The problem is that GCC 2.2.2 is
optimizing away `if (x == 0) x = 0;', but this optimization is incorrect
for the case where x is -0.0 in IEEE floating point.
Technical Details
Message-ID:
<9208110514.AA23551@shadow.twinsun.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!shadow.TWinsun.COM!eggertShow Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!shadow.TWinsun.COM!eggert From: eggert@shadow.TWinsun.COM (Paul Eggert) Subject: Re: IEEE zero problem Message-ID: <9208110514.AA23551@shadow.twinsun.com> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Tue, 11 Aug 1992 05:14:24 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 26