🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Paul Eggert Tue, 11 Aug 1992 05:14
Re: IEEE zero problem
#332
Author: Paul Eggert
Date: Tue, 11 Aug 1992 05:14
25 lines
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.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads