Mail Archives: djgpp/1996/09/30/05:04:13
Ian Viemeister wrote:
>
> This is odd. I checked, and found exactly the same problem (fifth call
> to ldexp always causes SIGFPE). HOWEVER, if you leave off the "-lm",
> and use the non-math library ldexp, no floating-point error occurs.
> As the obivous quick-fix, Guillermo, just don't link with libm.a
>
> ***Note to whoever is currently maintaining the math libs:
> Is this a general bug, or is it possibly related to a particular setup?
>
I am not maintaining the library, but here is an answer :
This is a "general" bug : it seems to happen because some function
(*_scalb.s) forgets to pop from the stack some data after pushing it on.
Hence, the stack gets corrupted after a few calls of exponential
functions (not only ldexp), and your program bombs with a FPE signal,
sometimes on some seemingly harmless calculation (eg, an addition...).
This bug has been corrected (dig the newsgroup archives at delorie.com
for information on this), but as you say, you can workaround by not
linking -lm (you then are using the default math functions of the C
library). This worked for me, but you should be aware that:
1/ not linking -lm results in faster calculation (on my 486DX at least)
2/ a few functions are missing in libc.a : namely Bessel functions, and
the Gamma function (not much used heh?)
3/ I am told libm.a functions do a better handling of errors and
exceptions...
I have also been told that libm.a functions are more precise, but I do
not think so (or at least not by a sensible margin).
Anyway, if you need extremely precise math functions, you should never
rely on library functions...
Hope this helps
Francois
- Raw text -