diff options
author | Bruno Haible <bruno@clisp.org> | 2007-03-25 19:56:22 +0000 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2007-03-25 19:56:22 +0000 |
commit | 6136fd62a3342532f17ccfd5f24db97764978448 (patch) | |
tree | 029aea01610d2017c5dab016682206afa6004548 /tests/test-isnan.c | |
parent | d2c57e54a1f805be7c7859f12962a3804a4a635d (diff) | |
download | gnulib-6136fd62a3342532f17ccfd5f24db97764978448.tar.gz |
Work around a DEC C compiler bug.
Diffstat (limited to 'tests/test-isnan.c')
-rw-r--r-- | tests/test-isnan.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/test-isnan.c b/tests/test-isnan.c index 445c30a3f5..0897a55b32 100644 --- a/tests/test-isnan.c +++ b/tests/test-isnan.c @@ -26,6 +26,18 @@ #define ASSERT(expr) if (!(expr)) abort (); +/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */ +#ifdef __DECC +static double +NaN () +{ + static double zero = 0.0; + return zero / zero; +} +#else +# define NaN() (0.0 / 0.0) +#endif + int main () { @@ -40,7 +52,7 @@ main () ASSERT (!isnan (1.0 / 0.0)); ASSERT (!isnan (-1.0 / 0.0)); /* Quiet NaN. */ - ASSERT (isnan (0.0 / 0.0)); + ASSERT (isnan (NaN ())); #if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT /* Signalling NaN. */ { @@ -48,7 +60,7 @@ main () ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) typedef union { double value; unsigned int word[NWORDS]; } memory_double; memory_double m; - m.value = 0.0 / 0.0; + m.value = NaN (); # if DBL_EXPBIT0_BIT > 0 m.word[DBL_EXPBIT0_WORD] ^= (unsigned int) 1 << (DBL_EXPBIT0_BIT - 1); # else |