[gnu.gcc.bug] Floating-point constants lose on Sun-3

rang@cpsin3.cps.msu.edu (Anton Rang) (12/01/88)

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 <math.h>

	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 |                      |
+---------------------------+------------------------+----------------------+