🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #310

IEEE zero problem

#310
From: Peter Miller
Date: Fri, 07 Aug 1992 19:51
33 lines
1373 bytes
Dear Sir,

IEEE has two representations for zero: -0.0 and +0.0.

The optimizer appears to think that there is only one.

For example:
	if (x == 0. && x < 0.)
		x = 0.;
if a line of code I use to make sure that zeros are always printed as positive.
The optimizer thinks the test is always false, which is not the case.

Another thing I tried was
	if (x == 0.)
		x = 0.;
which the optimizer promptly removed.

This behaviour is not correct, becauses there are two values of x which
equal 0.0 in IEEE fp math, and the optimizer erroneously thinks there is
only one.  The IEEE defn also asserts that -0. < 0.  Sigh.

I am using gcc-2.2.2 configured as sparc-sun-sunos4.1.
Is there a patach available to fix this mis-optimization?

The work around I am using is
	#ifdef __GNUC__
	__volatile__
	#endif
	double	x;
which looks rather groteque but does what I want (defeats the optimization).

Regards
Peter Miller
Technical Details
Message-ID: <9208062351.AA28887@garnet.bmr.gov.au>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!garnet.bmr.gov.au!pmiller

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!garnet.bmr.gov.au!pmiller
From: pmiller@garnet.bmr.gov.au (Peter Miller)
Subject: IEEE zero problem
Message-ID: <9208062351.AA28887@garnet.bmr.gov.au>
Sender: gnulists@ai.mit.edu
Reply-To: Peter Miller <pmiller@garnet.bmr.gov.au>
Organization: GNUs Not Usenet
Distribution: gnu
Date: Fri, 7 Aug 1992 19:51:40 GMT
Approved: bug-gcc@prep.ai.mit.edu
Lines: 34