Sam James <[email protected]> writes:

> Sam James <[email protected]> writes:
>
>> Paul Eggert <[email protected]> writes:
>>
>>> On 2025-11-06 09:59, Sam James wrote:
>>>> With GCC trunk (built today) on x86_64-pc-linux-gnu, everything passes
>>>> with 9.8, but with this snapshot, I see one failure in the gnulib suite:
>>>> FAIL: test-stdcountof-h
>>>
>>> Can you reproduce this with just Gnulib? E.g., take the attached
>>> tarball, which I generated from Gnulib with './gnulib-tool
>>> --create-testdir --dir gnulib-test-stdcountof-h stdcountof-h', and
>>> run:
>>>
>>>   tar xf gnulib-test-stdcountof-h.tgz
>>>   ./configure
>>>   make check
>>>
>>> I just now tried this and it worked for me on Fedora 42 x86-64 with
>>> gcc 15.2.1 20251022 (Red Hat 15.2.1-3); if it's failing with GCC trunk
>>> it'd be interesting to see why.
>>
>> That indeed fails, and it passes if I use GCC 15:
>>
>> Good: gcc version 15.2.1 20251101 (Gentoo Hardened 15.2.1_p20251101 p1)
>> Bad: gcc version 16.0.0 20251106 (experimental) 
>> 1139d69306d67aeeb0ee13a8d2a367933afda8e4 (Gentoo Hardened 16.0.9999 p, 
>> commit e79963c291a5666ef91c5b048db5993960266b36)
>>
>> I'll bisect GCC.
>
> Having actually looked at it, it's now obvious. GCC trunk implements
> _Countof (PR117025). And indeed, diffing a builddir w/ 15 vs trunk:
>
>  /* Define to 1 if you have the <stdcountof.h> header file. */
> -/* #undef HAVE_STDCOUNTOF_H */
> +#define HAVE_STDCOUNTOF_H 1
>
> --- gnulib-test-stdcountof-h-gcc15/gllib/stdcountof.h   2025-11-06 
> 23:51:33.925338704 +0000
> +++ gnulib-test-stdcountof-h/gllib/stdcountof.h 2025-11-06 23:52:40.133065974 
> +0000
> @@ -24,7 +24,7 @@
>
>
>  /* The include_next requires a split double-inclusion guard.  */
> -#if (defined __cplusplus ? 0 : 0)
> +#if (defined __cplusplus ? 0 : 1)
>  # include_next <stdcountof.h>
>  #else
>
> .. and that module wasn't in the last coreutils release.

#include <stdcountof.h>
#include <stddef.h>

int bounded[10];

void foo ()
{
  static_assert (_Generic (countof (bounded), size_t: 1, default: 0));
}

This works for me with Clang 21.1.5 and fails with GCC trunk, with
-std=gnu2y. What behaviour is it supposed to have?

I remember reading somewhere some discussion about whether Countof
should give you a size_t, but I can't find it now.

Reply via email to