Bug 6793 - logb() does not set errno on pole error
Summary: logb() does not set errno on pole error
Status: NEW
Alias: None
Product: glibc
Classification: Unclassified
Component: math (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2008-07-31 09:35 UTC by Michael Kerrisk
Modified: 2020-05-23 11:37 UTC (History)
1 user (show)

See Also:
Last reconfirmed:
fweimer: security-

test program (2.72 KB, text/plain)
2008-07-31 09:36 UTC, Michael Kerrisk

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Kerrisk 2008-07-31 09:35:09 UTC
On a pole error, logb() correctly raises an exception, but does not set errno. 
errno should be set to ERANGE.

(Note that log(), log2(), log10() *do* set errno for a pole error)

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 09:36:37 UTC
Created attachment 2855 [details]
test program

Sample run showing problem:

$ /tmp/mt_logb 0
errno == 0
fetestexcept() says:  FE_DIVBYZERO
Comment 2 Joseph Myers 2012-03-01 02:20:51 UTC
Confirmed with current sources on both x86 and x86_64.
Comment 3 Michael Kerrisk 2020-05-23 11:37:03 UTC
Still present in glibc 2.31 (tested on x86_64).