From 9946e7a949d3b0f2795d930aa2f2ce7bda5e4f8a Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Wed, 8 Jun 2016 21:32:57 +0000 Subject: Fix ldexp, scalbn, scalbln for sNaN input (bug 20225). The wrapper implementations of ldexp / scalbn / scalbln (architecture-independent), and their float / long double variants, return sNaN for sNaN input. This patch fixes them to add relevant arguments to themselves so that qNaN is returned in this case. Tested for x86_64 and x86. [BZ #20225] * math/s_ldexp.c (__ldexp): Add non-finite or zero argument to itself. * math/s_ldexpf.c (__ldexpf): Likewise. * math/s_ldexpl.c (__ldexpl): Likewise. * math/w_scalbln.c (__w_scalbln): Likewise. * math/w_scalblnf.c (__w_scalblnf): Likewise. * math/w_scalblnl.c (__w_scalblnl): Likewise. * math/libm-test.inc (scalbn_test_data): Add sNaN tests. (scalbln_test_data): Likewise. --- math/s_ldexpl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'math/s_ldexpl.c') diff --git a/math/s_ldexpl.c b/math/s_ldexpl.c index f34c805bda..52fb093171 100644 --- a/math/s_ldexpl.c +++ b/math/s_ldexpl.c @@ -24,7 +24,7 @@ static char rcsid[] = "$NetBSD: $"; long double __ldexpl(long double value, int exp) { - if(!isfinite(value)||value==0.0) return value; + if(!isfinite(value)||value==0.0) return value + value; value = __scalbnl(value,exp); if(!isfinite(value)||value==0.0) __set_errno (ERANGE); return value; -- cgit v1.2.3