Hi Sam, Paul, Joseph, Sorry to all for the format of this email. I can't fetch any email at the moment (the mbsync(1) is reporting some error with the IMAP). I'll paste parts of what I see in the mailing list and in the webmail. I'll also have issues replying to mail until this is fixed, hopefully soon.
Sam said: > test-stdcountof-h.c:88: assertion '_Generic (countof (bounded), size_t: 1, > default: 0)' failed I can reproduce. We should add this test to GCC. At the moment I have issues with email, so please someone else send a patch to GCC. Paul said: > Can you reproduce this with just Gnulib? [...] > if it's failing with GCC trunk it'd be interesting to see why. It doesn't fail on GCC 15, because gnulib falls back to its own definition of countof(). GCC 16 is the first version of GCC that provides countof(), and that implementation is what causes the issue in gnulib. So, the bug is actually in GCC. [Later both of you find out the same thing.] Sam said: > I remember reading somewhere some discussion about whether Countof > should give you a size_t, but I can't find it now. The ISO C standard. The latest draft is n3685. <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3685.pdf#subsubsection.0.6.5.4.5> 6.5.4.5p6: The value of the result of all operators is implementation-defined, and its type (an unsigned integer type) is size_t, defined in <stddef.h> (and other headers). Sam said: > I'll file a GCC bug. Thanks! > Thanks for probing. It's strange because Alejandro > both recently touched these tests in gnulib and also wrote the support > in GCC. He also commented on the PR which added a test in Clang that GCC > fails (this exact behaviour). I forgot to add this test in GCC. I've now probed this with the following program, to see what's going on: alx@devuan:~/tmp$ cat c.c #include <stddef.h> #include <stdio.h> int main(void) { int x; short i[1]; x = _Generic(_Countof(i), char: 1, signed char: 2, short: 3, int: 4, long: 5, long long: 6, unsigned char: 7, unsigned short: 8, unsigned int: 9, unsigned long: 10, unsigned long long: 11, default: 12); printf("%d\n", x); typeof(_Countof(i)) *p = NULL; size_t *q = p; } alx@devuan:~/tmp$ /opt/local/gnu/gcc/fwd_incomp4/bin/gcc -Wall -Wextra c.c c.c: In function ‘main’: c.c:27:35: error: initialization of ‘size_t *’ {aka ‘long unsigned int *’} from incompatible pointer type ‘sizetype *’ [-Wincompatible-pointer-types] 27 | size_t *q = p; | ^ c.c:27:31: warning: unused variable ‘q’ [-Wunused-variable] 27 | size_t *q = p; | ^ alx@devuan:~/tmp$ sed -i -e '/typeof/s,^,//,' -e '/size_t/s,^,//,' c.c alx@devuan:~/tmp$ /opt/local/gnu/gcc/fwd_incomp4/bin/gcc -Wall -Wextra c.c alx@devuan:~/tmp$ ./a.out 12 This 'sizetype' is something that goes beyond my GCC knowledge. I've CCd Joseph, as he'll probably be able to help. For some reason, GCC is not tying this sizetype to size_t with _Countof(). Sam said: > For the benefit of the list, this is now > <https://gcc.gnu.org/PR122591>. And of course no action is required on the > gnulib or coreutils side. Thanks again. Yup, I confirm. This is a bug in the GCC implementation of _Countof() that I wrote. Sorry and thanks! :) Have a lovely night! Alex -- <https://www.alejandro-colomar.es> Use port 80 (that is, <...:80/>).
signature.asc
Description: PGP signature
