With clang 21, released last week, there is a compilation error in the
stdcountof-h tests:
/home/bruno/inst-clang/21.1.0/bin/clang
-Wl,-rpath,/home/bruno/inst-clang/21.1.0/lib -std=gnu23 -DHAVE_CONFIG_H
-DEXEEXT=\"\" -DEXEEXT=\"\" -I. -I../../gltests -I..
-DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests -I..
-I../../gltests/.. -I../gllib -I../../gltests/../gllib
-I/media/develdata/devel/inst-x86_64-64/include -Wall -Wthread-safety
-Wno-error -Wno-error -g -O2 -MT test-stdcountof-h.o -MD -MP -MF $depbase.Tpo
-c -o test-stdcountof-h.o ../../gltests/test-stdcountof-h.c &&\
mv -f $depbase.Tpo $depbase.Po
../../gltests/test-stdcountof-h.c:45:10: error: use of undeclared identifier
'_gl_verify_is_array'
45 | (void) _gl_verify_is_array (unbounded);
| ^~~~~~~~~~~~~~~~~~~
../../gltests/test-stdcountof-h.c:46:10: error: use of undeclared identifier
'_gl_verify_is_array'
46 | (void) _gl_verify_is_array (bounded);
| ^~~~~~~~~~~~~~~~~~~
../../gltests/test-stdcountof-h.c:47:10: error: use of undeclared identifier
'_gl_verify_is_array'
47 | (void) _gl_verify_is_array (multidimensional);
| ^~~~~~~~~~~~~~~~~~~
3 errors generated.
make[3]: *** [Makefile:27092: test-stdcountof-h.o] Error 1
The cause is that when the compiler already has <stdcountof.h>, our override
.h file does not get created, and thus _gl_verify_is_array is not defined.
2025-09-08 Bruno Haible <[email protected]>
stdcountof-h tests: Fix compilation error with clang 21.
* tests/test-stdcountof-h.c (test_func): Don't use _gl_verify_is_array
if it's not defined.
diff --git a/tests/test-stdcountof-h.c b/tests/test-stdcountof-h.c
index 5d0a9a6611..b64bd9d58b 100644
--- a/tests/test-stdcountof-h.c
+++ b/tests/test-stdcountof-h.c
@@ -42,17 +42,21 @@ test_func (int parameter[3])
(void) local_bounded;
+#ifdef _gl_verify_is_array
(void) _gl_verify_is_array (unbounded);
(void) _gl_verify_is_array (bounded);
(void) _gl_verify_is_array (multidimensional);
+#endif
ASSERT (countof (bounded) == 10);
ASSERT (countof (multidimensional) == 10);
ASSERT (countof (local_bounded) == 20);
#if 0 /* These produce compilation errors. */
+# ifdef _gl_verify_is_array
(void) _gl_verify_is_array (integer);
(void) _gl_verify_is_array (parameter);
+# endif
ASSERT (countof (integer) >= 0);
ASSERT (countof (unbounded) >= 0);