[comp.lang.c] Strange Behavior -- AT&T Std C

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

Here's the source:

#include <stdio.h>
#include <math.h>
void main()
{
	printf("Exp(0) = %f\n", exp(0.0));
	printf("Exp(1) = %f\n", exp(1.0));
	printf("Exp(-1) = %f\n", exp(-1.0));
}


Here's a typescript of the compilation, execution, and debugging runs:

Script is typescript, started Thu Apr 18 10:41:28 1991

mccc [pjh] /usr/pjh/c> cc -g -o y y.c -lm

mccc [pjh] /usr/pjh/c> y
Floating exception(coredump)

mccc [pjh] /usr/pjh/c> sdb y
no source file				WHY DOES SDB SAY THIS????
0x2cc 	(exp+368:)	   ffree  %st(5)	[ %st(5) ]
*r
./y 
SIGNALED 8 process 4444
0x2cc 	(exp+368:)	   ffree  %st(5)	[ %st(5) ]
*s
SIGNALED 8 process 4444
0x2ce 	(exp+370:)	   popl   %edi	[ %edi ]
*s
STEPPED process 4444 function main() in y.c
6:		printf("Exp(1) = %f\n", exp(1.0));
*s
STEPPED process 4444 function main() in y.c
7:		printf("Exp(-1) = %f\n", exp(-1.0));
*s
SIGNALED 8 process 4444
0x2ce 	(exp+370:)	   popl   %edi	[ %edi ]
*s
STEPPED process 4444 function main() in y.c
7:		printf("Exp(-1) = %f\n", exp(-1.0));
*s
STEPPED process 4444 function main() in y.c
8:	}
*s
Exp(0) = 1.000000
Exp(1) = 2.718282
Exp(-1) = 0.367879		GOOD LORD!  IT DID THE CALCULATIONS!!
Process 4444 has terminated.
*s
Can't step process, it's a core file.
*q
mccc [pjh] /usr/pjh/c>

Script done Thu Apr 18 10:42:23 1991

This was done, incidentally, both with the original libm.a (that I was
*so* sure was buggy!) and a borrowed copy of a later version of libm.a!!

What on earth can be causing the "Floating exception(coredump)"????

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

daw@cbnewsh.att.com (David Wolverton) (04/20/91)

In article <1991Apr18.144759.4492@mccc.edu>, pjh@mccc.edu (Peter J. Holsberg) writes:
> Here's the source:
	[lots deleted]

If your system is using IEEE 754-based floating point (which
has a good probability of being true), then it is possible
to ask the floating point subsystem to signal several types
of f.p. exceptions, including "inexact" (that is, that a
computation had to round off a result).  Normally, you would
never want to enable this particular signal, but if it was
enabled, it would probably fire on ANY call to exp(), because
it would be very unlikely that exp()'s internal computations
would be completely roundoff-free.

Dave Wolverton
daw@honshu.att.com

jfv@cbnewsk.att.com (j.f.van valkenburg) (04/22/91)

In article <1991Apr18.144759.4492@mccc.edu>, pjh@mccc.edu (Peter J. Holsberg) writes:
> Here's the source:
> 
> #include <stdio.h>
> #include <math.h>
> void main()
> {
> 	printf("Exp(0) = %f\n", exp(0.0));
> 	printf("Exp(1) = %f\n", exp(1.0));
> 	printf("Exp(-1) = %f\n", exp(-1.0));
> }
> 
> 
> Here's a typescript of the compilation, execution, and debugging runs:
> 
> Script is typescript, started Thu Apr 18 10:41:28 1991
> 
	various messages


I tried it on my 3B2/1000 running SVR3.2.2

and it complied with no burps and ran smooth

I compiled cc foo.c -lm -o foo


result was 
Exp(0) = 1.000000
Exp(1) = 2.718282
Exp(-1) = 0.367879



I don't know what happened but, I had no trouble.



------------------------
James F. Van Valkenburg         a.k.a.  "van"
AT&T 				Attmail: !jfv               jfv@cbnewsk.att.com
Atlanta, GA.			Voice  404-873-7920
===============================================================================

   ---- Standard Disclaimers included -- Just another grunt at AT&T ----

===============================================================================

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

In article <1991Apr22.164400.20859@cbnewsk.att.com> jfv@cbnewsk.att.com (j.f.van valkenburg) writes:
=
=I tried it on my 3B2/1000 running SVR3.2.2
=
=and it complied with no burps and ran smooth

I should point out that everyone else who has tried it has not had the
problem, but that no one has exactly the same software I have.  Please,
if you have AT&T UNIX SV/386 R3.2.2 and SCDE 5.0/3, try the program and
let me know what happens.

If you have a different R3.2.x and/or a different SCDE, please try it,
too.  Incidentally, the "S" in "SCDE" stands for "Standard" as in "ANSI."

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