]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Make zero volatile to defeat constant-folding of 0.0/0.0
authorStan Shebs <stanshebs@google.com>
Tue, 23 Jan 2018 16:28:31 +0000 (08:28 -0800)
committerStan Shebs <stanshebs@google.com>
Thu, 25 Jan 2018 00:03:40 +0000 (16:03 -0800)
sysdeps/ieee754/dbl-64/e_log.c
sysdeps/ieee754/k_standard.c

index 6a18ebb904fc42a69ed72d79f6db646addf46054..1558a2ec4e080076a1c002b5dfe4ab01bb0508c5 100644 (file)
@@ -69,6 +69,8 @@ __ieee754_log (double x)
   number num;
   mp_no mpx, mpy, mpy1, mpy2, mperr;
 
+  volatile double zero = 0.0;
+
 #include "ulog.tbl"
 #include "ulog.h"
 
@@ -81,9 +83,9 @@ __ieee754_log (double x)
   if (__glibc_unlikely (ux < 0x00100000))
     {
       if (__glibc_unlikely (((ux & 0x7fffffff) | dx) == 0))
-       return MHALF / 0.0;     /* return -INF */
+       return MHALF / zero;     /* return -INF */
       if (__glibc_unlikely (ux < 0))
-       return (x - x) / 0.0;   /* return NaN  */
+       return (x - x) / zero;   /* return NaN  */
       n -= 54;
       x *= two54.d;             /* scale x     */
       num.d = x;
index f74f9c712e92e45c9b7fdfa592c6f13f55fc4605..f0436cc4a107eaf6d27a09d1570df2f5159662b9 100644 (file)
@@ -38,7 +38,7 @@ static char rcsid[] = "$NetBSD: k_standard.c,v 1.6 1995/05/10 20:46:35 jtc Exp $
 # if 0
 static const double zero = 0.0;        /* used as const */
 # else
-static double zero = 0.0;      /* used as const */
+volatile static double zero = 0.0;     /* used as const */
 # endif
 
 /*