Sources Bugzilla – Bug 6806
y0(), y1(), yn() do not raise exception on underflow
Last modified: 2012-03-01 17:51:07 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).
Created attachment 2874 [details] test program
Created attachment 2875 [details] test program
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
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).
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.