]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
[BZ #15335, #15342] Fix standard compliance. Don't use hard-coded qNaN values.
authorThomas Schwinge <thomas@codesourcery.com>
Wed, 3 Apr 2013 20:00:21 +0000 (22:00 +0200)
committerThomas Schwinge <thomas@codesourcery.com>
Fri, 5 Apr 2013 20:27:29 +0000 (22:27 +0200)
ChangeLog
NEWS
sysdeps/ieee754/dbl-64/e_pow.c
sysdeps/ieee754/dbl-64/upow.h

index b96a33330da4c1ac243a651dbfd672520e19f511..f0abe722a7e402c10df607e14f045fc155b6e3b5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2013-04-05  Thomas Schwinge  <thomas@codesourcery.com>
 
+       [BZ #15335, #15342]
+       * sysdeps/ieee754/dbl-64/upow.h (NaNQ): Remove definitions.
+       * sysdeps/ieee754/dbl-64/e_pow.c (__ieee754_pow): Instead, use
+       input NaN values or generate a qNaN by arithmetic operation.
+
        * sysdeps/ieee754/dbl-64/e_pow.c (__ieee754_pow): Remove
        unreachable code.
 
diff --git a/NEWS b/NEWS
index 8577030c6266caf26bfaed88ba2540f881e7c717..3a39baf0fcd39ad9bed665a254548572f29d35ff 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -13,7 +13,7 @@ Version 2.18
   14317, 14327, 14478, 14496, 14812, 14920, 14964, 14981, 14982, 14985,
   14994, 14996, 15003, 15006, 15020, 15023, 15036, 15054, 15055, 15062,
   15078, 15160, 15214, 15232, 15234, 15283, 15285, 15287, 15304, 15305,
-  15307, 15327, 15330, 15337.
+  15307, 15327, 15330, 15335, 15337, 15342.
 
 * CVE-2013-0242 Buffer overrun in regexp matcher has been fixed (Bugzilla
   #15078).
index 44d6f62398899e4f016614ec067a1aa9e5cedbf8..9a766e7224a91ef2edacecc32ed0e35629b736cc 100644 (file)
@@ -71,8 +71,9 @@ __ieee754_pow(double x, double y) {
   u.x=x;
   if (v.i[LOW_HALF] == 0) { /* of y */
     qx = u.i[HIGH_HALF]&0x7fffffff;
-    /* Checking  if x is not too small to compute */
-    if (((qx==0x7ff00000)&&(u.i[LOW_HALF]!=0))||(qx>0x7ff00000)) return NaNQ.x;
+    /* Is x a NaN?  */
+    if (((qx == 0x7ff00000) && (u.i[LOW_HALF] != 0)) || (qx > 0x7ff00000))
+      return x;
     if (y == 1.0) return x;
     if (y == 2.0) return x*x;
     if (y == -1.0) return 1.0/x;
@@ -111,7 +112,7 @@ __ieee754_pow(double x, double y) {
 
   if (x == 0) {
     if (((v.i[HIGH_HALF] & 0x7fffffff) == 0x7ff00000 && v.i[LOW_HALF] != 0)
-       || (v.i[HIGH_HALF] & 0x7fffffff) > 0x7ff00000)
+       || (v.i[HIGH_HALF] & 0x7fffffff) > 0x7ff00000) /* NaN */
       return y;
     if (ABS(y) > 1.0e20) return (y>0)?0:1.0/0.0;
     k = checkint(y);
@@ -124,9 +125,10 @@ __ieee754_pow(double x, double y) {
   qx = u.i[HIGH_HALF]&0x7fffffff;  /*   no sign   */
   qy = v.i[HIGH_HALF]&0x7fffffff;  /*   no sign   */
 
-  if (qx >= 0x7ff00000 && (qx > 0x7ff00000 || u.i[LOW_HALF] != 0)) return NaNQ.x;
-  if (qy >= 0x7ff00000 && (qy > 0x7ff00000 || v.i[LOW_HALF] != 0))
-    return x == 1.0 ? 1.0 : NaNQ.x;
+  if (qx >= 0x7ff00000 && (qx > 0x7ff00000 || u.i[LOW_HALF] != 0)) /* NaN */
+    return x;
+  if (qy >= 0x7ff00000 && (qy > 0x7ff00000 || v.i[LOW_HALF] != 0)) /* NaN */
+    return x == 1.0 ? 1.0 : y;
 
   /* if x<0 */
   if (u.i[HIGH_HALF] < 0) {
@@ -139,7 +141,7 @@ __ieee754_pow(double x, double y) {
       }
       else if (qx == 0x7ff00000)
        return y < 0 ? 0.0 : INF.x;
-      return NaNQ.x;                              /* y not integer and x<0 */
+      return (x - x) / (x - x);                   /* y not integer and x<0 */
     }
     else if (qx == 0x7ff00000)
       {
index 67bae1aefca118aed4578810a7982aaaf8e2027e..130fb3296fec32c03b1c693e92bb8e9b6c98a0d9 100644 (file)
@@ -34,7 +34,6 @@
 /**/ nZERO         = {{0x80000000, 0}},          /* -0.0          */
 /**/ INF            = {{0x7ff00000, 0x00000000}}, /* INF           */
 /**/ nINF           = {{0xfff00000, 0x00000000}}, /* -INF          */
-/**/ NaNQ           = {{0x7ff80000, 0x00000000}}, /* NaNQ          */
 /**/ sqrt_2         = {{0x3ff6a09e, 0x667f3bcc}}, /* sqrt(2)       */
 /**/ ln2a           = {{0x3fe62e42, 0xfefa3800}}, /* ln(2) 43 bits */
 /**/ ln2b           = {{0x3d2ef357, 0x93c76730}}, /* ln(2)-ln2a    */
@@ -49,7 +48,6 @@
 /**/ nZERO         = {{0, 0x80000000}},          /* -0.0          */
 /**/ INF            = {{0x00000000, 0x7ff00000}}, /* INF           */
 /**/ nINF           = {{0x00000000, 0xfff00000}}, /* -INF           */
-/**/ NaNQ           = {{0x00000000, 0x7ff80000}}, /* NaNQ          */
 /**/ sqrt_2         = {{0x667f3bcc, 0x3ff6a09e}}, /* sqrt(2)       */
 /**/ ln2a           = {{0xfefa3800, 0x3fe62e42}}, /* ln(2) 43 bits */
 /**/ ln2b           = {{0x93c76730, 0x3d2ef357}}, /* ln(2)-ln2a    */