Bug 6777 - lgamma() pole error sets errno to EDOM, should be ERANGE
Summary: lgamma() pole error sets errno to EDOM, should be ERANGE
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: math (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Andreas Jaeger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-30 10:55 UTC by Michael Kerrisk
Modified: 2014-07-04 05:47 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
test program (2.72 KB, text/plain)
2008-07-31 08:25 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-30 10:55:15 UTC
For the pole error, POSIX.1 says of lgamma():

Pole Error
    The x argument is a negative integer or zero.

    If the integer expression (math_errhandling & MATH_ERRNO) is non-zero, then
errno shall be set to [ERANGE]. If the integer expression (math_errhandling &
MATH_ERREXCEPT) is non-zero, then the divide-by-zero floating-point exception
shall be raised.
==

glibc 2.8's lgamma() does raise the divide-by-zero exception, as expected.

It also sets errno, but to the wrong value: errno is set to EDOM, when it should
instead be ERANGE.
Comment 1 Michael Kerrisk 2008-07-31 08:25:19 UTC
Created attachment 2842 [details]
test program

Attached a test program.  Sample run showing the problem:

$ /tmp/mt_lgamma -- -1
errno == EDOM
fetestexcept() says:  FE_DIVBYZERO
lgamma(-1.00000000000000000e+00)=inf
EDOM FE_DIVBYZERO +inf
Comment 2 Michael Kerrisk 2010-09-11 14:21:40 UTC
This bug appears to have been fixed in glibc 2.10, and man-pages-3.27 is updated
accordingly.