Building a testdir of totalorder, totalorderf, totalorderl,
totalordermag, totalordermagf, totalordermagl on AIX 7.1 with xlc,
I see these compilation errors:

xlc -qthreaded -qtls -DHAVE_CONFIG_H -I. -I../../gltests -I..  
-DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests -I.. 
-I../../gltests/.. -I../gllib -I../../gltests/../gllib 
-I/home/haible/prefix32/include  -g -c -o test-totalorder.o 
../../gltests/test-totalorder.c
"../../gltests/test-totalorder.h", line 48.33: 1506-196 (S) Initialization 
between types "double" and "union {...}" is not allowed.
"../../gltests/test-totalorder.h", line 49.33: 1506-196 (S) Initialization 
between types "double" and "union {...}" is not allowed.
"../../gltests/test-totalorder.h", line 51.32: 1506-196 (S) Initialization 
between types "double" and "union {...}" is not allowed.
"../../gltests/test-totalorder.h", line 64.32: 1506-196 (S) Initialization 
between types "double" and "union {...}" is not allowed.
"../../gltests/test-totalorder.h", line 66.33: 1506-196 (S) Initialization 
between types "double" and "union {...}" is not allowed.
"../../gltests/test-totalorder.h", line 67.33: 1506-196 (S) Initialization 
between types "double" and "union {...}" is not allowed.
gmake[4]: *** [Makefile:1960: test-totalorder.o] Error 1

xlc -qthreaded -qtls -DHAVE_CONFIG_H -I. -I../../gltests -I..  
-DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests -I.. 
-I../../gltests/.. -I../gllib -I../../gltests/../gllib 
-I/home/haible/prefix32/include  -g -c -o test-totalorderf.o 
../../gltests/test-totalorderf.c
"../../gltests/test-totalorder.h", line 48.33: 1506-196 (S) Initialization 
between types "float" and "union {...}" is not allowed.
"../../gltests/test-totalorder.h", line 49.33: 1506-196 (S) Initialization 
between types "float" and "union {...}" is not allowed.
"../../gltests/test-totalorder.h", line 51.32: 1506-196 (S) Initialization 
between types "float" and "union {...}" is not allowed.
"../../gltests/test-totalorder.h", line 64.32: 1506-196 (S) Initialization 
between types "float" and "union {...}" is not allowed.
"../../gltests/test-totalorder.h", line 66.33: 1506-196 (S) Initialization 
between types "float" and "union {...}" is not allowed.
"../../gltests/test-totalorder.h", line 67.33: 1506-196 (S) Initialization 
between types "float" and "union {...}" is not allowed.
gmake[4]: *** [Makefile:1960: test-totalorderf.o] Error 1

xlc -qthreaded -qtls -DHAVE_CONFIG_H -I. -I../../gltests -I..  
-DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests -I.. 
-I../../gltests/.. -I../gllib -I../../gltests/../gllib 
-I/home/haible/prefix32/include  -g -c -o test-totalorderl.o 
../../gltests/test-totalorderl.c
"../../gltests/test-totalorder.h", line 48.33: 1506-196 (S) Initialization 
between types "long double" and "union {...}" is not allowed.
"../../gltests/test-totalorder.h", line 49.33: 1506-196 (S) Initialization 
between types "long double" and "union {...}" is not allowed.
"../../gltests/test-totalorder.h", line 51.32: 1506-196 (S) Initialization 
between types "long double" and "union {...}" is not allowed.
"../../gltests/test-totalorder.h", line 64.32: 1506-196 (S) Initialization 
between types "long double" and "union {...}" is not allowed.
"../../gltests/test-totalorder.h", line 66.33: 1506-196 (S) Initialization 
between types "long double" and "union {...}" is not allowed.
"../../gltests/test-totalorder.h", line 67.33: 1506-196 (S) Initialization 
between types "long double" and "union {...}" is not allowed.
gmake[4]: *** [Makefile:1960: test-totalorderl.o] Error 1

and likewise for the test-totalordermag* tests.

I don't want to pessimize the readability of this code, for the sake of a
broken proprietary and dead compiler. Therefore this workaround:


2024-06-02  Bruno Haible  <br...@clisp.org>

        totalorder*: Avoid compilation error by IBM XL C compiler.
        * tests/test-totalorder.h (main) [__IBMC__]: Skip the test.
        * tests/test-totalordermag.h (main) [__IBMC__]: Likewise.

diff --git a/tests/test-totalorder.h b/tests/test-totalorder.h
index fd437160bf..ef8c6b121d 100644
--- a/tests/test-totalorder.h
+++ b/tests/test-totalorder.h
@@ -16,12 +16,28 @@
 
 #include <stdio.h>
 
+/* Specification.  */
 #include <math.h>
-#include "infinity.h"
-#include "macros.h"
-#include "minus-zero.h"
-#include "signed-nan.h"
-#include "signed-snan.h"
+
+#if defined __IBMC__
+/* The IBM XL C compiler cannot compile the initializer of x[] below.  */
+
+# include <stdio.h>
+
+int
+main ()
+{
+  fputs ("Skipping test: broken C compiler\n", stderr);
+  return 77;
+}
+
+#else
+
+# include "infinity.h"
+# include "macros.h"
+# include "minus-zero.h"
+# include "signed-nan.h"
+# include "signed-snan.h"
 
 static TOTALORDER_TYPE
 positive_NaN_with_payload (int payload)
@@ -47,9 +63,9 @@ main ()
     {
       negative_NaN_with_payload (1729),
       negative_NaN_with_payload (641),
-#if TOTALORDER_HAVE_SNAN
+# if TOTALORDER_HAVE_SNAN
       TOTALORDER_NEGATIVE_SNAN (),
-#endif
+# endif
       { -TOTALORDER_INF () },
       { -1e37 },
       { -1 },
@@ -60,9 +76,9 @@ main ()
       { 1 },
       { 1e37 },
       { TOTALORDER_INF () },
-#if TOTALORDER_HAVE_SNAN
+# if TOTALORDER_HAVE_SNAN
       TOTALORDER_POSITIVE_SNAN (),
-#endif
+# endif
       positive_NaN_with_payload (641),
       positive_NaN_with_payload (1729)
     };
@@ -78,3 +94,5 @@ main ()
 
   return test_exit_status;
 }
+
+#endif
diff --git a/tests/test-totalordermag.h b/tests/test-totalordermag.h
index 11990cda3d..94f929f39e 100644
--- a/tests/test-totalordermag.h
+++ b/tests/test-totalordermag.h
@@ -16,12 +16,28 @@
 
 #include <stdio.h>
 
+/* Specification.  */
 #include <math.h>
-#include "infinity.h"
-#include "macros.h"
-#include "minus-zero.h"
-#include "signed-nan.h"
-#include "signed-snan.h"
+
+#if defined __IBMC__
+/* The IBM XL C compiler cannot compile the initializer of x[] below.  */
+
+# include <stdio.h>
+
+int
+main ()
+{
+  fputs ("Skipping test: broken C compiler\n", stderr);
+  return 77;
+}
+
+#else
+
+# include "infinity.h"
+# include "macros.h"
+# include "minus-zero.h"
+# include "signed-nan.h"
+# include "signed-snan.h"
 
 static TOTALORDER_TYPE
 positive_NaN_with_payload (int payload)
@@ -47,9 +63,9 @@ main ()
     {
       negative_NaN_with_payload (1729),
       negative_NaN_with_payload (641),
-#if TOTALORDER_HAVE_SNAN
+# if TOTALORDER_HAVE_SNAN
       TOTALORDER_NEGATIVE_SNAN (),
-#endif
+# endif
       { -TOTALORDER_INF () },
       { -1e37 },
       { -1 },
@@ -60,9 +76,9 @@ main ()
       { 1 },
       { 1e37 },
       { TOTALORDER_INF () },
-#if TOTALORDER_HAVE_SNAN
+# if TOTALORDER_HAVE_SNAN
       TOTALORDER_POSITIVE_SNAN (),
-#endif
+# endif
       positive_NaN_with_payload (641),
       positive_NaN_with_payload (1729)
     };
@@ -79,3 +95,5 @@ main ()
 
   return test_exit_status;
 }
+
+#endif




Reply via email to