From 0b7a5f920163d03806d7c5d9d1c83b16942c9496 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Thu, 14 May 2015 23:38:07 +0000 Subject: Fix log1p missing underflows (bug 16339). Similar to various other bugs in this area, some log1p implementations do not raise the underflow exception for subnormal arguments, when the result is tiny and inexact. This patch forces the exception in a similar way to previous fixes. (The ldbl-128ibm implementation doesn't currently need any change as it already generates this exception, albeit through code that would generate spurious exceptions in other cases; special code for this issue will only be needed there when fixing the spurious exceptions.) Tested for x86_64, x86, powerpc and mips64. [BZ #16339] * sysdeps/i386/fpu/s_log1p.S (dbl_min): New object. (__log1p): Force underflow exception for results with small absolute value. * sysdeps/i386/fpu/s_log1pf.S (flt_min): New object. (__log1pf): Force underflow exception for results with small absolute value. * sysdeps/ieee754/dbl-64/s_log1p.c: Include . (__log1p): Force underflow exception for results with small absolute value. * sysdeps/ieee754/flt-32/s_log1pf.c: Include . (__log1pf): Force underflow exception for results with small absolute value. * sysdeps/ieee754/ldbl-128/s_log1pl.c: Include . (__log1pl): Force underflow exception for results with small absolute value. * math/auto-libm-test-in: Do not allow missing underflow exceptions from log1p. * math/auto-libm-test-out: Regenerated. --- sysdeps/ieee754/ldbl-128/s_log1pl.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sysdeps/ieee754/ldbl-128') diff --git a/sysdeps/ieee754/ldbl-128/s_log1pl.c b/sysdeps/ieee754/ldbl-128/s_log1pl.c index b70a55b758..ff759bc000 100644 --- a/sysdeps/ieee754/ldbl-128/s_log1pl.c +++ b/sysdeps/ieee754/ldbl-128/s_log1pl.c @@ -53,6 +53,7 @@ . */ +#include #include #include @@ -140,6 +141,11 @@ __log1pl (long double xm1) if ((hx & 0x7fffffff) < 0x3f8e0000) { + if (fabsl (xm1) < LDBL_MIN) + { + long double force_underflow = xm1 * xm1; + math_force_eval (force_underflow); + } if ((int) xm1 == 0) return xm1; } -- cgit 1.4.1