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-sprintf-posix.h | |
parent | d2c57e54a1f805be7c7859f12962a3804a4a635d (diff) | |
download | gnulib-6136fd62a3342532f17ccfd5f24db97764978448.tar.gz |
Work around a DEC C compiler bug.
Diffstat (limited to 'tests/test-sprintf-posix.h')
-rw-r--r-- | tests/test-sprintf-posix.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/test-sprintf-posix.h b/tests/test-sprintf-posix.h index 1efd931e78..b5153c5283 100644 --- a/tests/test-sprintf-posix.h +++ b/tests/test-sprintf-posix.h @@ -17,6 +17,18 @@ /* Written by Bruno Haible <bruno@clisp.org>, 2007. */ +/* 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 + static void test_function (int (*my_sprintf) (char *, const char *, ...)) { @@ -129,7 +141,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...)) { /* NaN. */ char result[1000]; int retval = - my_sprintf (result, "%a %d", 0.0 / 0.0, 33, 44, 55); + my_sprintf (result, "%a %d", NaN (), 33, 44, 55); ASSERT (strcmp (result, "nan 33") == 0); ASSERT (retval == strlen (result)); } @@ -322,7 +334,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...)) { /* FLAG_ZERO with NaN. */ char result[1000]; int retval = - my_sprintf (result, "%010a %d", 0.0 / 0.0, 33, 44, 55); + my_sprintf (result, "%010a %d", NaN (), 33, 44, 55); ASSERT (strcmp (result, " nan 33") == 0); ASSERT (retval == strlen (result)); } |