[comp.lang.c] exp

pjh@mccc.edu (Peter J. Holsberg) (03/19/91)

I have a program:

#include <stdio.h>
#include <math.h>
main()
{
	double y;
	y=exp(1.0);
}

that compiles OK but dumps core when run (the message is 'Floating
exception').  Running 'strings' on the binary yields:

@(#)/usr/ccs/lib/libm.a/exp.o.sl 1.1 5.0-3 11/05/89 65417 AT&T-SF 0.0

I'm using the AT&T Standard C (i.e., "ANSI C") Development Environment
(SCDE) 5.0/3 05/25/90 on a 6386 running AT&T UNIX System V/386 R3.2 2.2.

'sum /usr/ccs/lib/libm.a' yields
	17278 147 libm.a

The Hot Line says that they have an identical setup and that it works
perfectly on theirs.  I'm baffled.

Help!  Please....

Thanks,
Pete
-- 
Prof. Peter J. Holsberg      Mercer County Community College
Voice: 609-586-4800          Engineering Technology, Computers and Math
UUCP:...!princeton!mccc!pjh  1200 Old Trenton Road, Trenton, NJ 08690
Internet: pjh@mccc.edu	     Trenton Computer Festival -- 4/20-21/91

decot@hpisod2.cup.hp.com (Dave Decot) (03/22/91)

> I have a program:
> 
> #include <stdio.h>
> #include <math.h>
> main()
> {
> 	double y;
> 	y=exp(1.0);
> }
> 
> that compiles OK but dumps core when run (the message is 'Floating
> exception').  Running 'strings' on the binary yields:
> 
> @(#)/usr/ccs/lib/libm.a/exp.o.sl 1.1 5.0-3 11/05/89 65417 AT&T-SF 0.0
> 
> I'm using the AT&T Standard C (i.e., "ANSI C") Development Environment
> (SCDE) 5.0/3 05/25/90 on a 6386 running AT&T UNIX System V/386 R3.2 2.2.
> 
> 'sum /usr/ccs/lib/libm.a' yields
> 	17278 147 libm.a

I presume that you are linking with -lm, and that a declaration of
exp() returning double is found in <math.h>?

Are you using a "floats is floats" option to the compiler?

Dave Decot

pjh@mccc.edu (Pete Holsberg) (03/24/91)

In article <2550162@hpisod2.cup.hp.com> decot@hpisod2.cup.hp.com (Dave Decot) writes:
=> I have a program:
=> 
=> #include <stdio.h>
=> #include <math.h>
=> main()
=> {
=> 	double y;
=> 	y=exp(1.0);
=> }
=> 
=> that compiles OK but dumps core when run (the message is 'Floating
=> exception').  Running 'strings' on the binary yields:
=> 
=> @(#)/usr/ccs/lib/libm.a/exp.o.sl 1.1 5.0-3 11/05/89 65417 AT&T-SF 0.0
=> 
=> I'm using the AT&T Standard C (i.e., "ANSI C") Development Environment
=> (SCDE) 5.0/3 05/25/90 on a 6386 running AT&T UNIX System V/386 R3.2 2.2.
=> 
=> 'sum /usr/ccs/lib/libm.a' yields
=> 	17278 147 libm.a
=
=I presume that you are linking with -lm, and that a declaration of
=exp() returning double is found in <math.h>?

You presume correctly, sir!

=Are you using a "floats is floats" option to the compiler?

No idea what that means.

The AT&T HotLine folk claim that they can compile and execute that code
on a 386 with the same version of UNIX and the same SCDE.  I suppose
that means that I have a buggy libm.a, but how to get a copy of the
unbuggy one is a new question!

Pete
-- 
Prof. Peter J. Holsberg      Mercer County Community College
Voice: 609-586-4800          Engineering Technology, Computers and Math
UUCP:...!princeton!mccc!pjh  1200 Old Trenton Road, Trenton, NJ 08690
Internet: pjh@mccc.edu	     Trenton Computer Festival -- 4/20-21/91

pjh@mccc.edu (Peter J. Holsberg) (04/24/91)

To those of you who have been following the thread, the HOT LINE just
called to say that they were able to duplicate exp()'s failure on any
value but 0.0 (by removing the 80387 from their system).

Thanks to all who tried to help.  I expect a bug fix "real soon now."

Pete
-- 
Prof. Peter J. Holsberg      Mercer County Community College
Voice: 609-586-4800          Engineering Technology, Computers and Math
UUCP:...!princeton!mccc!pjh  1200 Old Trenton Road, Trenton, NJ 08690
Internet: pjh@mccc.edu	     Trenton Computer Festival -- 4/20-21/91

pjh@mccc.edu (Peter J. Holsberg) (04/26/91)

The HOT LINE just called to say that the bug that caused
exp(any_number_but 0.0) to dump core was in the "floating point driver"
in the SV/386 R3.2.2 kernel, and that a patch would be mailed. They also
said that the bug was fixed in 3.2.3 but as I don't have a maintenance
contract for 3.2.2, I wasn't notified.

Thanks to everyone who tried to help.

Pete
-- 
Prof. Peter J. Holsberg      Mercer County Community College
Voice: 609-586-4800          Engineering Technology, Computers and Math
UUCP:...!princeton!mccc!pjh  1200 Old Trenton Road, Trenton, NJ 08690
Internet: pjh@mccc.edu	     Trenton Computer Festival -- 4/20-21/91