Hi Alejandro,
> 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++.
Gnulib's <stdcountof.h> is meant to work in C++ mode. We actually have
a unit test for that: gnulib/tests/test-stdcountof-h-c++.cc .
> $ 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
When we fix a bug, we always first need to reproduce it.
The information you gave is not sufficient for allowing us to reproduce
it. Please provide the following:
- The patch you are using, relative to groff's master branch.
Please provide it as an attachment, not inline in the mail,
because some mail providers mangle text outside of attachments.
- The platform (distro in case of the GNU/Linux system).
- The compiler (gcc or clang? which version?)
- The output of "make V=1". We need to see the compiler commands,
not some information-less shortcut.
Thanks.
Bruno