]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix cexp (NaN + i0) (bug 15532).
authorJoseph Myers <joseph@codesourcery.com>
Fri, 23 Aug 2013 19:45:38 +0000 (19:45 +0000)
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Thu, 31 Oct 2013 15:04:32 +0000 (10:04 -0500)
ChangeLog
NEWS
math/libm-test.inc
math/s_cexp.c
math/s_cexpf.c
math/s_cexpl.c

index 7b4d6e9214acdd76147193355b606c1e395d2145..1ffcad440b4fb005f75748bfc40086c0816d4db4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2013-08-23  Joseph Myers  <joseph@codesourcery.com>
+
+       [BZ #15532]
+       * math/s_cexp.c (__cexp): Return NaN + i0 for NaN + i0 argument.
+       * math/s_cexpf.c (__cexpf): Likewise.
+       * math/s_cexpl.c (__cexpl): Likewise.
+       * math/libm-test.inc (cexp_test_data): Correct expected return
+       value for NaN + i0.  Add another test.
+
 2013-08-21  Joseph Myers  <joseph@codesourcery.com>
 
        [BZ #15797]
diff --git a/NEWS b/NEWS
index 0d0a315da5134efd7f874cdd66f011fdff4cca64..c83a14e980dc3fd239458dfa1d62907f070dc848 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -20,9 +20,9 @@ Version 2.18
   15335, 15336, 15337, 15339, 15342, 15346, 15359, 15361, 15366, 15380,
   15381, 15394, 15395, 15405, 15406, 15409, 15416, 15418, 15419, 15423,
   15424, 15426, 15429, 15431, 15432, 15441, 15442, 15448, 15465, 15480,
-  15485, 15488, 15490, 15492, 15493, 15497, 15506, 15529, 15536, 15553,
-  15577, 15583, 15618, 15627, 15631, 15654, 15655, 15666, 15667, 15674,
-  15711, 15755, 15759, 15797.
+  15485, 15488, 15490, 15492, 15493, 15497, 15506, 15529, 15532, 15536,
+  15553, 15577, 15583, 15618, 15627, 15631, 15654, 15655, 15666, 15667,
+  15674, 15711, 15755, 15759, 15797.
 
 * CVE-2013-2207 Incorrectly granting access to another user's pseudo-terminal
   has been fixed by disabling the use of pt_chown (Bugzilla #15755).
index 8c1dcac8e8a92afe00d7e92081849e1b4958b609..7408c6b312ecbd8f2891ad53ea238554f1c5deb8 100644 (file)
@@ -6193,7 +6193,8 @@ static const struct test_c_c_data cexp_test_data[] =
 
     TEST_c_c (cexp, plus_infty, qnan_value, plus_infty, qnan_value),
 
-    TEST_c_c (cexp, qnan_value, 0.0, qnan_value, qnan_value, INVALID_EXCEPTION_OK),
+    TEST_c_c (cexp, qnan_value, 0.0, qnan_value, 0.0),
+    TEST_c_c (cexp, qnan_value, minus_zero, qnan_value, minus_zero),
     TEST_c_c (cexp, qnan_value, 1.0, qnan_value, qnan_value, INVALID_EXCEPTION_OK),
 
     TEST_c_c (cexp, qnan_value, plus_infty, qnan_value, qnan_value, INVALID_EXCEPTION_OK),
index 655e4e8deebca91450f982281cab3b70683e2d88..40e0e518d2ac40dca769c82621a5cbe2f35e1d10 100644 (file)
@@ -145,12 +145,18 @@ __cexp (__complex__ double x)
     }
   else
     {
-      /* If the real part is NaN the result is NaN + iNaN.  */
+      /* If the real part is NaN the result is NaN + iNaN unless the
+        imaginary part is zero.  */
       __real__ retval = __nan ("");
-      __imag__ retval = __nan ("");
+      if (icls == FP_ZERO)
+       __imag__ retval = __imag__ x;
+      else
+       {
+         __imag__ retval = __nan ("");
 
-      if (rcls != FP_NAN || icls != FP_NAN)
-       feraiseexcept (FE_INVALID);
+         if (rcls != FP_NAN || icls != FP_NAN)
+           feraiseexcept (FE_INVALID);
+       }
     }
 
   return retval;
index fa942d34f79526a3fc5fb29896d468ae3d52ea17..7c422051644e4d91afbc1a2b9e65bbb9796d2379 100644 (file)
@@ -145,12 +145,18 @@ __cexpf (__complex__ float x)
     }
   else
     {
-      /* If the real part is NaN the result is NaN + iNaN.  */
+      /* If the real part is NaN the result is NaN + iNaN unless the
+        imaginary part is zero.  */
       __real__ retval = __nanf ("");
-      __imag__ retval = __nanf ("");
+      if (icls == FP_ZERO)
+       __imag__ retval = __imag__ x;
+      else
+       {
+         __imag__ retval = __nanf ("");
 
-      if (rcls != FP_NAN || icls != FP_NAN)
-       feraiseexcept (FE_INVALID);
+         if (rcls != FP_NAN || icls != FP_NAN)
+           feraiseexcept (FE_INVALID);
+       }
     }
 
   return retval;
index d827bc3de41a70a544704b2564ecc6b2bacf3838..0c356033666f3f415c136a04eb6a1ba8753658c3 100644 (file)
@@ -145,12 +145,18 @@ __cexpl (__complex__ long double x)
     }
   else
     {
-      /* If the real part is NaN the result is NaN + iNaN.  */
+      /* If the real part is NaN the result is NaN + iNaN unless the
+        imaginary part is zero.  */
       __real__ retval = __nanl ("");
-      __imag__ retval = __nanl ("");
+      if (icls == FP_ZERO)
+       __imag__ retval = __imag__ x;
+      else
+       {
+         __imag__ retval = __nanl ("");
 
-      if (rcls != FP_NAN || icls != FP_NAN)
-       feraiseexcept (FE_INVALID);
+         if (rcls != FP_NAN || icls != FP_NAN)
+           feraiseexcept (FE_INVALID);
+       }
     }
 
   return retval;