Bug 6805 - j0(), j1(), jn() do not raise exceptions on underflow error
: j0(), j1(), jn() do not raise exceptions on underflow error
Status: NEW
Product: glibc
Classification: Unclassified
Component: math
: unspecified
: P2 normal
: ---
Assigned To: Not yet assigned to anyone
:
:
:
:
  Show dependency treegraph
 
Reported: 2008-07-31 11:27 UTC by Michael Kerrisk
Modified: 2012-03-01 17:50 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
test program (11.47 KB, text/plain)
2008-07-31 11:28 UTC, Michael Kerrisk
Details
test program (11.47 KB, text/plain)
2008-07-31 11:28 UTC, Michael Kerrisk
Details
test program (11.53 KB, text/plain)
2008-07-31 11:29 UTC, Michael Kerrisk
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Kerrisk 2008-07-31 11:27:39 UTC
On an underflow error, j0(), j1(), and jn() correctly set errno to ERANGE, but
do not raise an IEEE exception.  They should raise the FE_UNDERFLOW exception.

Background: 
On error, many glibc math functions both set errno and raise an exception
(fetestexcept(3)).  For example, the following  function all do this: acos(),
asin(), cosh(), sinh(), acosh(), asinh(), exp(), exp2(), ldexp(), log(),
log10(), log2().  However, there is much inconsistency.  Some functions raise an
exception, but don't set errno.  Some functions set errno for some errors, but
not others.  A few set errno, but don't raise an exception.  This series of bug
reports documents deviations from what I consider the ideal: all functions
should BOTH set errno AND raise an exception for all errors.

All of these reports relate to tests on glibc 2.8 (as provided by SUSE 11.0).
Comment 1 Michael Kerrisk 2008-07-31 11:28:09 UTC
Created attachment 2871 [details]
test program
Comment 2 Michael Kerrisk 2008-07-31 11:28:36 UTC
Created attachment 2872 [details]
test program
Comment 3 Michael Kerrisk 2008-07-31 11:29:50 UTC
Created attachment 2873 [details]
test program

Sample runs demonstrating the problem:

$ /tmp/mt_j0 1e100
errno == ERANGE
fetestexcept() says:  FE_INEXACT
j0(1.00000000000000002e+100)=0.00000000000000000e+00
ERANGE 0 +0

$ /tmp/mt_j1 1e100
errno == ERANGE
fetestexcept() says:  FE_INEXACT
j1(1.00000000000000002e+100)=0.00000000000000000e+00
ERANGE 0 +0

$ /tmp/mt_jn 10 1e100
errno == ERANGE
fetestexcept() says:  FE_INEXACT
jn(10,1.00000000000000002e+100)=0.00000000000000000e+00
ERANGE 0 +0
Comment 4 Joseph Myers 2012-03-01 17:50:32 UTC
See http://sourceware.org/ml/libc-alpha/2012-02/msg00512.html - the correct
result won't underflow in these cases but in whatever cases TLOSS errors are
given I suppose underflow should be raised as well.