bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: msvc support: avoid division bug


From: Bruno Haible
Subject: Re: msvc support: avoid division bug
Date: Sat, 17 Sep 2011 18:01:24 +0200
User-agent: KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; )

> The MSVC 9 compiler gives a compilation error for a division through a
> literal whose value is zero.

This necessitates also this workaround, to avoid compilation errors in lines
133, 134, 135 of lib/isnan.c.


2011-09-17  Bruno Haible  <address@hidden>

        isnanl, isnand, isnanf: Work around MSVC bug.
        * lib/isnan.c (FUNC): Use alternate ways of computing NaN and Infinity.

--- lib/isnan.c.orig    Sat Sep 17 17:57:32 2011
+++ lib/isnan.c Sat Sep 17 17:57:05 2011
@@ -117,17 +117,20 @@
 # else
   /* Be careful to not do any floating-point operation on x, such as x == x,
      because x may be a signaling NaN.  */
-#  if defined __TINYC__ || defined __SUNPRO_C || defined __DECC \
-      || (defined __sgi && !defined __GNUC__) || defined __ICC
-  /* The Sun C 5.0, Intel ICC 10.0, and Compaq (ex-DEC) 6.4 compilers don't
-     recognize the initializers as constant expressions.  The latter compiler
-     also fails when constant-folding 0.0 / 0.0 even when constant-folding is
-     not required.  The SGI MIPSpro C compiler complains about "floating-point
-     operation result is out of range".  */
+#  if defined __SUNPRO_C || defined __ICC || defined _MSC_VER \
+      || defined __DECC || defined __TINYC__ \
+      || (defined __sgi && !defined __GNUC__)
+  /* The Sun C 5.0, Intel ICC 10.0, Microsoft Visual C/C++ 9.0, Compaq (ex-DEC)
+     6.4, and TinyCC compilers don't recognize the initializers as constant
+     expressions.  The Compaq compiler also fails when constant-folding
+     0.0 / 0.0 even when constant-folding is not required.  The Microsoft
+     Visual C/C++ compiler also fails when constant-folding 1.0 / 0.0 even
+     when constant-folding is not required. The SGI MIPSpro C compiler
+     complains about "floating-point operation result is out of range".  */
   static DOUBLE zero = L_(0.0);
   memory_double nan;
-  DOUBLE plus_inf = L_(1.0) / L_(0.0);
-  DOUBLE minus_inf = -L_(1.0) / L_(0.0);
+  DOUBLE plus_inf = L_(1.0) / zero;
+  DOUBLE minus_inf = -L_(1.0) / zero;
   nan.value = zero / zero;
 #  else
   static memory_double nan = { L_(0.0) / L_(0.0) };

-- 
In memoriam Estella Agsteribbe <http://en.wikipedia.org/wiki/Estella_Agsteribbe>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]