Path: utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!mailrus!eecae!cps3xx!rang
From: rang@cpsin3.cps.msu.edu (Anton Rang)
Newsgroups: gnu.gcc.bug
Subject: Floating-point constants lose on Sun-3 (GCC 1.31)
Summary: Constants which are too large assemble (incorrectly) to "Infinity"
Message-ID: <1208@cps3xx.UUCP>
Date: 1 Dec 88 02:10:37 GMT
Sender: usenet@cps3xx.UUCP
Reply-To: rang@cpswh.cps.msu.edu (Anton Rang)
Organization: Michigan State University, Computer Science Dept.
Lines: 31

On a Sun-3/280 (SunOS 3.4, GCC 1.31) the following program can
generate bad assembly code.  A warning message is produced
(x.c:7: warning: floating point number exceeds range of `double') but
the generated code is wrong with optimization on.

	#include 

	main()
	{
	  float f;

	  f = HUGE;		/* Defined by Sun to be 99.e999 */
	  printf("%f\n", f);
	}

Without optimization, the constant is stored in memory as:

	.long 0x7f800000

which is (correctly) IEEE "infinity".  With optimization, this is
integrated into an "fmoves" instruction; apparently, a printf() or
similar call is used to format it, and the result is:

	fmoves #0rInfinity,fp0

which the assembler rejects.

+---------------------------+------------------------+----------------------+
| Anton Rang (grad student) | "VMS Forever!"         | "Do worry...be SAD!" |
| Michigan State University | rang@cpswh.cps.msu.edu |                      |
+---------------------------+------------------------+----------------------+