Hi! I'm trying to use countof() in groff, and I'm having some issues I don't understand. groff is written in C++, which I don't understand, so the issues might be due to something I just don't understand from C++, but I think it's likely to be a bug in gnulib's implementation of the array checker for C++.
$ make
make all-recursive
make[1]: Entering directory '/srv/alx/src/gnu/groff/master'
make[2]: Entering directory '/srv/alx/src/gnu/groff/master'
CXX src/devices/grotty/tty.o
In file included from src/devices/grotty/tty.cpp:26:
./lib/stdcountof.h: In instantiation of ‘struct _gl_verify_type<-1>’:
src/devices/grotty/tty.cpp:751:27: required from here
751 | const size_t buflen = countof("48;2;255;255;255m");
| ^~~~~~~
./lib/stdcountof.h:55:18: error: negative width in bit-field
‘_gl_verify_type<-1>::_gl_verify_error_if_negative’
55 | unsigned int _gl_verify_error_if_negative: w;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [Makefile:10661: src/devices/grotty/tty.o] Error 1
make[2]: Leaving directory '/srv/alx/src/gnu/groff/master'
make[1]: *** [Makefile:13042: all-recursive] Error 1
make[1]: Leaving directory '/srv/alx/src/gnu/groff/master'
make: *** [Makefile:7452: all] Error 2
As far as I can see, countof("...") should succeed, as the input is an
array (at least, it would be an array in C). Is C++ weird? Or is this
just a bug?
Have a lovely night!
Alex
--
<https://www.alejandro-colomar.es>
Use port 80 (that is, <...:80/>).
signature.asc
Description: PGP signature
