Floating exception bug

David Messer dave at viper.Lynx.MN.Org
Fri Dec 2 14:05:14 AEST 1988


I don't know if this has been reported yet, but the following code
causes a "Floating exception error" and a core dump when run in a
system with an 80287 co-processor.  (I don't know if it generates an
error when floating point operations are emulated with software.)

------File x.c
main()
{
	/*extern double y();*/
	for(;;) {
		y() ;
		}
	}
------File y.c
double
y()
{
	return( 1.0 ) ;
	}
------
Compile with:
	cc x.c y.c

and execute a.out.

The fix is to uncomment "extern double y();" in main().  Since the value
returned from y() is not used, no extern definition should be required.

Apparently if the function is not declared double, it uses up resources
in the floating-point chip which eventually causes an error.  It was a
real bear to find because the error could occur on any floating-point
operation once the resources got too low.
-- 
_____________________________________________________________________________
   __                     _ _ _              David Messer - Lynx Data Systems
  /  )              /    ' ) ) )                 dave at Lynx.MN.Org  -or-
 /  / __. , __o  __/      / / / _  _   _   _  __     ...{amdahl,hpda}!bungia!
/__/_(_/|_\\/ <__(_/_     / ' (_</_/_)_/_)_</_/ (_                 viper!dave



More information about the Comp.unix.microport mailing list