Bug 6806 - y0(), y1(), yn() do not raise exception on underflow
y0(), y1(), yn() do not raise exception on underflow
Status: NEW
Product: glibc
Classification: Unclassified
Component: math
unspecified
: P2 normal
: ---
Assigned To: Not yet assigned to anyone
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-07-31 11:58 UTC by Michael Kerrisk
Modified: 2012-03-01 17:51 UTC (History)
1 user (show)

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


Attachments
test program (11.47 KB, text/plain)
2008-07-31 12:00 UTC, Michael Kerrisk
Details
test program (11.47 KB, text/plain)
2008-07-31 12:01 UTC, Michael Kerrisk
Details
test program (11.47 KB, text/plain)
2008-07-31 12:02 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:58:34 UTC
On underflow, y0(), y1(), yn() correctly set errno to ERANGE, but do not raise
an IEEE underflow exception.  They should raise an 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 12:00:52 UTC
Created attachment 2874 [details]
test program
Comment 2 Michael Kerrisk 2008-07-31 12:01:27 UTC
Created attachment 2875 [details]
test program
Comment 3 Michael Kerrisk 2008-07-31 12:02:44 UTC
Created attachment 2876 [details]
test program

Sample runs demonstrating the problem

$ /tmp/mt_y0 dbl_max
errno == ERANGE
fetestexcept() says:  FE_INEXACT
y0(1.79769313486231571e+308)=0.00000000000000000e+00
ERANGE 0 +0

$ /tmp/mt_y1 dbl_max
errno == ERANGE
fetestexcept() says:  FE_INEXACT
y1(1.79769313486231571e+308)=0.00000000000000000e+00
ERANGE 0 +0

$ /tmp/mt_yn 10 dbl_max
errno == ERANGE
fetestexcept() says:  FE_INEXACT
yn(10,1.79769313486231571e+308)=0.00000000000000000e+00
ERANGE 0 +0
Comment 4 Michael Kerrisk 2008-07-31 12:33:49 UTC
In passing, it is worth noting that these functions do correctly set errno and
raise the right exception at least one other error (domain error).
Comment 5 Joseph Myers 2012-03-01 17:51:07 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.