From eef112c69472818b6aa3673505c24e1f41571b7d Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 17 Sep 2011 17:58:10 +0200 Subject: [PATCH] isnanl, isnand, isnanf: Work around MSVC bug. * lib/isnan.c (FUNC): Use alternate ways of computing NaN and Infinity. --- ChangeLog | 5 +++++ lib/isnan.c | 21 ++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index eda85bf29..62d4027cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2011-09-17 Bruno Haible + isnanl, isnand, isnanf: Work around MSVC bug. + * lib/isnan.c (FUNC): Use alternate ways of computing NaN and Infinity. + +2011-09-17 Bruno Haible + sys_socket tests: Fix recent mistake. * tests/test-sys_socket.c (t1): Avoid collision of identifiers. diff --git a/lib/isnan.c b/lib/isnan.c index d9c653dea..f26dc1ec1 100644 --- a/lib/isnan.c +++ b/lib/isnan.c @@ -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) }; -- 2.11.0