]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix dbl-64 asin (sNaN) (bug 20213).
authorJoseph Myers <joseph@codesourcery.com>
Mon, 6 Jun 2016 22:21:11 +0000 (22:21 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Mon, 6 Jun 2016 22:21:11 +0000 (22:21 +0000)
The dbl-64 version of asin returns sNaN for sNaN arguments.  This
patch fixes it to add NaN arguments to themselves so that qNaN is
returned in this case.

Tested for x86_64 and x86.

[BZ #20213]
* sysdeps/ieee754/dbl-64/e_asin.c (__ieee754_asin): Add NaN
argument to itself.
* math/libm-test.inc (asin_test_data): Add sNaN tests.

ChangeLog
math/libm-test.inc
sysdeps/ieee754/dbl-64/e_asin.c

index e207a710056bc267673e4f42f479b74c3ec48421..b839cfb11cab2cd53f4afed78cea9b361d8af332 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2016-06-06  Joseph Myers  <joseph@codesourcery.com>
+
+       [BZ #20213]
+       * sysdeps/ieee754/dbl-64/e_asin.c (__ieee754_asin): Add NaN
+       argument to itself.
+       * math/libm-test.inc (asin_test_data): Add sNaN tests.
+
 2016-06-06  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
        * misc/Makefile (CFLAGS-pwritev.c): New variable: add cancellation
index 698172080c21a6ddc64bd13b3465841f752a3d47..f9b2c8ada8112c8fa876204ee29379ff21e6e790 100644 (file)
@@ -1853,6 +1853,8 @@ static const struct test_f_f_data asin_test_data[] =
     TEST_f_f (asin, minus_infty, qnan_value, INVALID_EXCEPTION|ERRNO_EDOM),
     TEST_f_f (asin, qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
     TEST_f_f (asin, -qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_f_f (asin, snan_value, qnan_value, INVALID_EXCEPTION),
+    TEST_f_f (asin, -snan_value, qnan_value, INVALID_EXCEPTION),
 
     /* asin x == qNaN plus invalid exception for |x| > 1.  */
     TEST_f_f (asin, 1.125L, qnan_value, INVALID_EXCEPTION|ERRNO_EDOM),
index 5d5fb0113254834f6368ebbb05aa241bfd553770..23e9e7eddd8827eda465cc89903a8fec68ae9781 100644 (file)
@@ -323,7 +323,7 @@ __ieee754_asin(double x){
   /*---------------------------- |x|>=1 -------------------------------*/
   else if (k==0x3ff00000 && u.i[LOW_HALF]==0) return (m>0)?hp0.x:-hp0.x;
   else
-  if (k>0x7ff00000 || (k == 0x7ff00000 && u.i[LOW_HALF] != 0)) return x;
+  if (k>0x7ff00000 || (k == 0x7ff00000 && u.i[LOW_HALF] != 0)) return x + x;
   else {
     u.i[HIGH_HALF]=0x7ff00000;
     v.i[HIGH_HALF]=0x7ff00000;