From 88283451b26de29d08ba33148cf2f8cb2680f6f0 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Mon, 13 Jun 2016 17:27:19 +0000 Subject: Fix frexp (NaN) (bug 20250). Various implementations of frexp functions return sNaN for sNaN input. This patch fixes them to add such arguments to themselves so that qNaN is returned. Tested for x86_64, x86, mips64 and powerpc. [BZ #20250] * sysdeps/i386/fpu/s_frexpl.S (__frexpl): Add non-finite input to itself. * sysdeps/ieee754/dbl-64/s_frexp.c (__frexp): Add non-finite or zero input to itself. * sysdeps/ieee754/dbl-64/wordsize-64/s_frexp.c (__frexp): Likewise. * sysdeps/ieee754/flt-32/s_frexpf.c (__frexpf): Likewise. * sysdeps/ieee754/ldbl-128/s_frexpl.c (__frexpl): Likewise. * sysdeps/ieee754/ldbl-128ibm/s_frexpl.c (__frexpl): Likewise. * sysdeps/ieee754/ldbl-96/s_frexpl.c (__frexpl): Likewise. * math/libm-test.inc (frexp_test_data): Add sNaN tests. --- sysdeps/ieee754/dbl-64/wordsize-64/s_frexp.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sysdeps/ieee754/dbl-64/wordsize-64/s_frexp.c') diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_frexp.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_frexp.c index 42068f8187..4b075b7200 100644 --- a/sysdeps/ieee754/dbl-64/wordsize-64/s_frexp.c +++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_frexp.c @@ -55,6 +55,9 @@ __frexp (double x, int *eptr) ix = (ix & INT64_C (0x800fffffffffffff)) | INT64_C (0x3fe0000000000000); INSERT_WORDS64 (x, ix); } + else + /* Quiet signaling NaNs. */ + x += x; *eptr = e; return x; -- cgit 1.4.1