Paul Eggert wrote: > I introduced CALLN to Emacs in 2015 and it has proved useful.
OK, since you say it's useful, let's make sure that gnulib's countof macro supports this case. Done like this: 2025-06-07 Bruno Haible <br...@clisp.org> stdcountof-h: Work around a clang bug. Reported by Basil L. Contovounesios <ba...@contovou.net> in <https://lists.gnu.org/archive/html/bug-gnulib/2025-06/msg00073.html>. * lib/stdcountof.in.h (_gl_verify_is_array): Disable the checking on clang. * tests/test-stdcountof-h.c (test_func): Add another test case. diff --git a/lib/stdcountof.in.h b/lib/stdcountof.in.h index 105cf209a5..683b1c7156 100644 --- a/lib/stdcountof.in.h +++ b/lib/stdcountof.in.h @@ -81,7 +81,8 @@ template <typename T> _gl_array_type_test<T> _gl_array_type_test_helper(T&); # endif #else /* In C, we can use typeof and __builtin_types_compatible_p. */ -# if _GL_GNUC_PREREQ (3, 1) || defined __clang__ +/* Work around clang bug <https://github.com/llvm/llvm-project/issues/143284>. */ +# if _GL_GNUC_PREREQ (3, 1) && ! defined __clang__ /* || defined __clang__ */ # define _gl_verify_is_array(a) \ sizeof (struct { unsigned int _gl_verify_error_if_negative : __builtin_types_compatible_p (typeof (a), typeof (&*(a))) ? -1 : 1; }) # else diff --git a/tests/test-stdcountof-h.c b/tests/test-stdcountof-h.c index cd7e03f331..5d0a9a6611 100644 --- a/tests/test-stdcountof-h.c +++ b/tests/test-stdcountof-h.c @@ -58,6 +58,11 @@ test_func (int parameter[3]) ASSERT (countof (unbounded) >= 0); #endif + { + extern int a, b, c; + ASSERT (countof (((int[]) { a, b, c })) == 3); + } + /* Check that countof(...) is an expression of type size_t. */ #if !defined __cplusplus && HAVE__GENERIC ASSERT (_Generic (countof (bounded), size_t: 1, default: 0));