Another C compiler bug

Michael Meissner meissner at osf.org
Fri Nov 2 07:11:45 AEST 1990


In article <11565 at sybase.sybase.com> mcfong at mercury.sybase.com writes:

| When the following program is run:
| 
| 	main()
| 	{
| 		printf("7e-7 = %f\n", 7e-7);
| 	}
| 
| I get the following results on the following MIPS-based systems:
| 
| 	RISC ULTRIX 3.0			7e-7 = 0.000000
| 	SGI IRIX 3.2			7e-7 = 0.000000
| 	MIPS OS 1.0			7e-7 = 0.000001
| 
| Looks like yet another compiler bug which MIPS has fixed but DEC and
| SGI have not yet picked up.
| 
| Would someone please run the same program on the latest version of RISC
| ULTRIX (4.0) and SGI IRIX (3.3) and see if DEC or SGI have fixed the
| problem in their later releases?

I did some checking (doesn't anybody look at the machine code these
days), and it's not a compiler bug, but a library bug.  You can
demonstrate it by changing the program to:

	main()
	{
		printf ("7e-7 = %g\n", 7e-7);
	}

and it will print "7e-7 = 7e-07" on my Ultrix 3.1 system.  On OSF/1,
it prints the correct answer.  I used by the standard C compiler (on
Ultrix) and GCC (on Ultrix and OSF/1), and they give identical
results.  I suspect the bug is that the library does not round %f
entries, but truncates them instead.

--
Michael Meissner	email: meissner at osf.org		phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142

Do apple growers tell their kids money doesn't grow on bushes?



More information about the Comp.sys.sgi mailing list