paranoia results (C and Fortran)

Emil Hallin emil@cls.usask.ca
Mon Jul 12 16:55:00 GMT 1999


Hi,
The recent posting of fortran paranoia prompted me to look at the
results of both the C and the fortran versions using gcc version 2.96
19990711 (experimental) and GNU Fortran 0.5.25 19990711 (experimental)
on a PIII Linux box (Linux 2.2.5-22 #1 Wed Jun 2 09:17:03 EDT 1999 i686
unknown). Both these codes produce no flaws and no defects running under
MS windows compilers (Watcom and MS VC6). 

On Linux, the results are:
output of paranoia.c (no optimization):

DEFECT:  Calculated 7.38905609548934539e+00 for
	(1 + (-1.11022302462515654e-16) ^ (-1.80143985094819840e+16);
	differs from correct value by -3.44130679508225512e-09 .
	This much error may spoil financial
	calculations involving tiny interest rates.
Checking rounding on multiply, divide and add/subtract.
* is neither chopped nor correctly rounded.
/ is neither chopped nor correctly rounded.
Addition/Subtraction neither rounds nor chops.
Sticky bit used incorrectly or not at all.
FLAW:  lack(s) of guard digits or failure(s) to correctly round or chop
(noted above) count as one flaw in the final tally below.

output of fortran version of paranoia(-O2 -ffloat-store
-funroll-all-loops -mpentiumpro):

 DEFECT: Calculated (1-0.11102230E-15)**(-0.18014399E+17)
         differs from correct value by -0.34413068E-08
 This much error may spoil calculations such as compounded interest.

 CHECKING FOR ROUNDING IN MULTIPLY, DIVIDE AND ADD/SUBTRACT:
  MULTIPLICATION IS NEITHER CHOPPED NOR CORRECTLY ROUNDED.
  DIVISION IS NEITHER CHOPPED NOR CORRECTLY ROUNDED.
  Vector/Scalar Division not rounded or chopped
  ADD/SUBTRACT IS NEITHER CHOPPED NOR CORRECTLY ROUNDED.
  STICKY BIT USED INCORRECTLY OR NOT AT ALL.
 One flaw assessed for failure of a guard or rounding test.



Applying *any* level of optimization (O1-O5) to the C code results in a
multitude of serious defects according to the paranoia program, and the
for structure on line 1606 of the code becomes an infinite loop.
Applying any level of optimization to the Fortran code has no harmful
side effect.

Enclosed is a tar-ball containing the following files:

command_line_output: 	command line used to compile the code
paranoia.i
paranoia.c
results:		the results of Fortran (optimized) and C (not
			optimized) paranoia
optimized_results:	the "bad" results when optimization is turned on
system:			the output from "uname -a"

Not sure how this rates on the bug scale, but thought these results
might be interesting to some folks.
	emil
paranoia.tar.gz



More information about the Gcc-bugs mailing list