summaryrefslogtreecommitdiff
path: root/tests/test-sprintf-posix.h
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2007-03-25 19:56:22 +0000
committerBruno Haible <bruno@clisp.org>2007-03-25 19:56:22 +0000
commit6136fd62a3342532f17ccfd5f24db97764978448 (patch)
tree029aea01610d2017c5dab016682206afa6004548 /tests/test-sprintf-posix.h
parentd2c57e54a1f805be7c7859f12962a3804a4a635d (diff)
downloadgnulib-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.h16
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));
}