Bug 6778 - expm1() raises bogus underflow exception for -large
Summary: expm1() raises bogus underflow exception for -large
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: math (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-30 11:05 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: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-30 11:05:27 UTC
(glibc 2.8)
When expm1(x) is given a large negative x value (e.g., in the range -1e5 through
to -1e308), it correctly returns -1.

However, it also raises an underflow exception.  This is bogus.  The result has
not underflowed: the result is asymptotically close to 1 (not zero).
Comment 1 Michael Kerrisk 2008-07-31 08:29:06 UTC
Created attachment 2843 [details]
test program

Example runs showing problem:

$ /tmp/mt_expm1 -- -1e5
errno == 0
fetestexcept() says:  FE_UNDERFLOW FE_INEXACT
expm1(-1.00000000000000000e+05)=-1.00000000000000000e+00
0 FE_UNDERFLOW normal

$ /tmp/mt_expm1 -- -1e308
errno == 0
fetestexcept() says:  FE_UNDERFLOW FE_INEXACT
expm1(-1.00000000000000001e+308)=-1.00000000000000000e+00
0 FE_UNDERFLOW normal
Comment 2 Joseph Myers 2012-02-29 20:59:11 UTC
Confirmed on x86 with current sources.  Does not appear on x86_64.  This is a quality-of-implementation issue only, since C99 and C11 permit spurious underflow exceptions (as well as spurious inexact exceptions, and raising inexact even when the result is exact).
Comment 3 Joseph Myers 2012-07-06 11:19:45 UTC
Fixed for 2.17 by:

commit f17ac40d7cb8e8c462476b6ab703262f6b8f6da8
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Fri Jul 6 11:17:41 2012 +0000

    Fix expm1 spurious underflow exceptions (bug 6778).