isnanl, isnand, isnanf: Work around MSVC bug.
authorBruno Haible <bruno@clisp.org>
Sat, 17 Sep 2011 15:58:10 +0000 (17:58 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 17 Sep 2011 15:59:19 +0000 (17:59 +0200)
* lib/isnan.c (FUNC): Use alternate ways of computing NaN and Infinity.

ChangeLog
lib/isnan.c

index eda85bf..62d4027 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2011-09-17  Bruno Haible  <bruno@clisp.org>
 
+       isnanl, isnand, isnanf: Work around MSVC bug.
+       * lib/isnan.c (FUNC): Use alternate ways of computing NaN and Infinity.
+
+2011-09-17  Bruno Haible  <bruno@clisp.org>
+
        sys_socket tests: Fix recent mistake.
        * tests/test-sys_socket.c (t1): Avoid collision of identifiers.
 
index d9c653d..f26dc1e 100644 (file)
@@ -117,17 +117,20 @@ FUNC (DOUBLE x)
 # 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) };