]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix i386 cbrtl (sNaN) (bug 20224).
authorJoseph Myers <joseph@codesourcery.com>
Wed, 8 Jun 2016 21:02:40 +0000 (21:02 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Wed, 8 Jun 2016 21:02:40 +0000 (21:02 +0000)
The i386 version of cbrtl returns sNaN (without raising any
exceptions) for sNaN input.  This patch fixes it to add non-finite
arguments to themselves (the code path in question is also reached for
zero arguments, for which adding them to themselves is also harmless),
so that "invalid" is raised and qNaN returned.

Tested for x86_64 and x86.

[BZ #20224]
* sysdeps/i386/fpu/s_cbrtl.S (__cbrtl): Add non-finite or zero
argument to itself.
* math/libm-test.inc (cbrt_test_data): Add sNaN tests.

ChangeLog
math/libm-test.inc
sysdeps/i386/fpu/s_cbrtl.S

index 20e21393d099c7807096c1fdb9db6294ceb9c7bf..201516873b904a11978196875be9cfe8dc0adb9d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2016-06-08  Joseph Myers  <joseph@codesourcery.com>
+
+       [BZ #20224]
+       * sysdeps/i386/fpu/s_cbrtl.S (__cbrtl): Add non-finite or zero
+       argument to itself.
+       * math/libm-test.inc (cbrt_test_data): Add sNaN tests.
+
 2016-06-08  H.J. Lu  <hongjiu.lu@intel.com>
 
        [BZ #19776]
index 7913f447523c342cb771fbe57baaa67cfb95a94a..520f141446f8f9decb7d2b3e750e623aea91fd6d 100644 (file)
@@ -5875,6 +5875,8 @@ static const struct test_f_f_data cbrt_test_data[] =
     TEST_f_f (cbrt, minus_infty, minus_infty, ERRNO_UNCHANGED),
     TEST_f_f (cbrt, qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
     TEST_f_f (cbrt, -qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_f_f (cbrt, snan_value, qnan_value, INVALID_EXCEPTION),
+    TEST_f_f (cbrt, -snan_value, qnan_value, INVALID_EXCEPTION),
 
     AUTO_TESTS_f_f (cbrt),
   };
index 3bf170075b3470cd0b70b51c89bcee6b483d73bf..6a643131650d11e696a2c15e28c043c31dc713bb 100644 (file)
@@ -223,6 +223,7 @@ ENTRY(__cbrtl)
 
        /* Return the argument.  */
 1:     fldt    4(%esp)
+       fadd    %st
        ret
 END(__cbrtl)
 weak_alias (__cbrtl, cbrtl)