Bug 13705 - Bogus FPE on underflow for exp(double)
Summary: Bogus FPE on underflow for exp(double)
Alias: None
Product: glibc
Classification: Unclassified
Component: math (show other bugs)
Version: 2.15
: P2 normal
Target Milestone: ---
Assignee: Aurelien Jarno
Depends on:
Reported: 2012-02-17 21:08 UTC by law
Modified: 2014-06-26 15:21 UTC (History)
2 users (show)

See Also:
Last reconfirmed:
fweimer: security-

testcase (394 bytes, text/plain)
2012-02-17 21:08 UTC, law

Note You need to log in before you can comment on or make changes to this bug.
Description law 2012-02-17 21:08:39 UTC
Created attachment 6225 [details]

With floating point trapping enabled, *except* for "underflow"
and "inexact", exp(-1.0e40) will throw a Floating Point Exception.

How reproducible:
Every time.

Steps to Reproduce:
1. Compile attached test programme (g++ test1.cpp)
2. Run program

Actual results:
Floating point exception.

Expected results:
The value 0 should be printed.
Comment 1 Aurelien Jarno 2012-02-18 12:15:48 UTC
This should be fixed by:

Comment 2 Aurelien Jarno 2012-02-20 06:34:17 UTC
This is a different bug than the one fixed by the link I gave above.
Comment 3 Robin 2012-02-20 22:32:43 UTC
At lines 35 and 40 of w_exp.c, libm uses the floating point variant "kernel_standard_f" rather than the double variant "kernel_standard".

The implementation of kernel_standard_f in k_standard.c just maps double to float (for arguments and return value).  If kernel_standard_f is changed to kernel_standard in both places, the test program runs through without problems.
Comment 4 Aurelien Jarno 2012-02-21 13:52:31 UTC
Patches posted on:

Comment 5 Joseph Myers 2012-04-08 22:50:24 UTC
I have committed this patch as:

commit f77f12320635155da728a3c1adb75ff9914cf686
Author: Aurelien Jarno <aurelien@aurel32.net>
Date:   Sun Apr 8 22:45:13 2012 +0000

    Use __kernel_standard instead of __kernel_standard_f in exp wrapper (bug 13705).

and the obvious testcase patch for it as:

commit d2de7579f257386ba5c28dfca94fa8aef143b4e0
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Sun Apr 8 22:46:49 2012 +0000

    Do not allow overflow exception on exp underflow test (bug 13705).