Work around a DEC C compiler bug.
authorBruno Haible <bruno@clisp.org>
Sun, 25 Mar 2007 19:56:22 +0000 (19:56 +0000)
committerBruno Haible <bruno@clisp.org>
Sun, 25 Mar 2007 19:56:22 +0000 (19:56 +0000)
ChangeLog
tests/test-fprintf-posix.h
tests/test-frexp.c
tests/test-isnan.c
tests/test-printf-posix.h
tests/test-snprintf-posix.h
tests/test-sprintf-posix.h
tests/test-vasnprintf-posix.c
tests/test-vasprintf-posix.c

index ff4bf3c486bca73dca69a5b04961d4199c11d53a..842ecccc7ad812abb4a1acea6484f1a5050bfa24 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
 2007-03-25  Bruno Haible  <bruno@clisp.org>
 
+       * tests/test-frexp.c (NaN): New function/macro.
+       (main): Use it instead of 0.0 / 0.0.
+       * tests/test-isnan.c (NaN): New function/macro.
+       (main): Use it instead of 0.0 / 0.0.
+       * tests/test-vasnprintf-posix.c (NaN): New function/macro.
+       (test_function): Use it instead of 0.0 / 0.0.
+       * tests/test-vasprintf-posix.c (NaN): New function/macro.
+       (test_function): Use it instead of 0.0 / 0.0.
+       * tests/test-snprintf-posix.h (NaN): New function/macro.
+       (test_function): Use it instead of 0.0 / 0.0.
+       * tests/test-sprintf-posix.h (NaN): New function/macro.
+       (test_function): Use it instead of 0.0 / 0.0.
+       * tests/test-fprintf-posix.h (NaN): New function/macro.
+       (test_function): Use it instead of 0.0 / 0.0.
+       * tests/test-printf-posix.h (NaN): New function/macro.
+       (test_function): Use it instead of 0.0 / 0.0.
+
        * lib/isnan.c (FUNC): Work around a DEC C compiler bug.
 
 2007-03-25  Bruno Haible  <bruno@clisp.org>
index 9f1e3fa8e314e1b7af4ee1b717f459f49d605304..2d5eb9303a67070b7da2ece4b406039cee7584b6 100644 (file)
 
 /* 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_fprintf) (FILE *, const char *, ...))
 {
@@ -47,13 +59,13 @@ test_function (int (*my_fprintf) (FILE *, const char *, ...))
   my_fprintf (stdout, "%a %d\n", -1.0 / 0.0, 33, 44, 55);
 
   /* NaN.  */
-  my_fprintf (stdout, "%a %d\n", 0.0 / 0.0, 33, 44, 55);
+  my_fprintf (stdout, "%a %d\n", NaN (), 33, 44, 55);
 
   /* FLAG_ZERO with infinite number.  */
   my_fprintf (stdout, "%010a %d\n", 1.0 / 0.0, 33, 44, 55);
 
   /* FLAG_ZERO with NaN.  */
-  my_fprintf (stdout, "%010a %d\n", 0.0 / 0.0, 33, 44, 55);
+  my_fprintf (stdout, "%010a %d\n", NaN (), 33, 44, 55);
 
   /* Test the support of the POSIX/XSI format strings with positions.  */
 
index 3c2ea806b72a560a081513e736c5ac6c209d1f19..912ba200c314461c4688ac192f8aa40ba4e10132 100644 (file)
 
 #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
+
 static double
 my_ldexp (double x, int d)
 {
@@ -50,7 +62,7 @@ main ()
   { /* NaN.  */
     int exp = -9999;
     double mantissa;
-    x = 0.0 / 0.0;
+    x = NaN ();
     mantissa = frexp (x, &exp);
     ASSERT (mantissa != mantissa);
   }
index 445c30a3f53cc7b50d69a1f67523350791a96bc0..0897a55b328e22d7ab36147c708d2de5e5dd48bf 100644 (file)
 
 #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
index 04d3e550d083447ff36705f634d78bd769fd2d83..cd79a93c39cedda851f05d6985076b6b8f577ff3 100644 (file)
 
 /* 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_printf) (const char *, ...))
 {
@@ -47,13 +59,13 @@ test_function (int (*my_printf) (const char *, ...))
   my_printf ("%a %d\n", -1.0 / 0.0, 33, 44, 55);
 
   /* NaN.  */
-  my_printf ("%a %d\n", 0.0 / 0.0, 33, 44, 55);
+  my_printf ("%a %d\n", NaN (), 33, 44, 55);
 
   /* FLAG_ZERO with infinite number.  */
   my_printf ("%010a %d\n", 1.0 / 0.0, 33, 44, 55);
 
   /* FLAG_ZERO with NaN.  */
-  my_printf ("%010a %d\n", 0.0 / 0.0, 33, 44, 55);
+  my_printf ("%010a %d\n", NaN (), 33, 44, 55);
 
   /* Test the support of the POSIX/XSI format strings with positions.  */
 
index a32e33d8d2d28df12750862b5aa61d2b3e1ac91c..52ad5ece84ca4283c9421132298fc835ce934f70 100644 (file)
 
 /* 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_snprintf) (char *, size_t, const char *, ...))
 {
@@ -143,7 +155,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   { /* NaN.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%a %d", 0.0 / 0.0, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%a %d", NaN (), 33, 44, 55);
     ASSERT (strcmp (result, "nan 33") == 0);
     ASSERT (retval == strlen (result));
   }
@@ -336,7 +348,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     char result[100];
     int retval =
-      my_snprintf (result, sizeof (result), "%010a %d", 0.0 / 0.0, 33, 44, 55);
+      my_snprintf (result, sizeof (result), "%010a %d", NaN (), 33, 44, 55);
     ASSERT (strcmp (result, "       nan 33") == 0);
     ASSERT (retval == strlen (result));
   }
index 1efd931e78f8bb0ea1672c7f0319a4345b376257..b5153c5283cb2f556f59b4ec89d904cbc7af7510 100644 (file)
 
 /* 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));
   }
index 791d6c72c59c8b09d6f88207de11d9a6d0edae92..9b3785c8dc915de289de4f8c6b8052cd9aca154d 100644 (file)
 
 #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
+
 static void
 test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
 {
@@ -183,7 +195,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   { /* NaN.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%a %d", 0.0 / 0.0, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%a %d", NaN (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strcmp (result, "nan 33") == 0);
     ASSERT (length == strlen (result));
@@ -412,7 +424,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     size_t length;
     char *result =
-      my_asnprintf (NULL, &length, "%010a %d", 0.0 / 0.0, 33, 44, 55);
+      my_asnprintf (NULL, &length, "%010a %d", NaN (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strcmp (result, "       nan 33") == 0);
     ASSERT (length == strlen (result));
index 5b4389127c6ebee0760937411be35c10d86a4eb9..f903efb1598a84ceb8e0027f31e2fe9f962517dc 100644 (file)
 
 #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
+
 static void
 test_function (int (*my_asprintf) (char **, const char *, ...))
 {
@@ -164,7 +176,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   { /* NaN.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%a %d", 0.0 / 0.0, 33, 44, 55);
+      my_asprintf (&result, "%a %d", NaN (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strcmp (result, "nan 33") == 0);
     ASSERT (retval == strlen (result));
@@ -393,7 +405,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
   { /* FLAG_ZERO with NaN.  */
     char *result;
     int retval =
-      my_asprintf (&result, "%010a %d", 0.0 / 0.0, 33, 44, 55);
+      my_asprintf (&result, "%010a %d", NaN (), 33, 44, 55);
     ASSERT (result != NULL);
     ASSERT (strcmp (result, "       nan 33") == 0);
     ASSERT (retval == strlen (result));