I had this error when building (if I remember correctly) libxcrypt for the initrd with genkernel. But genkernel is now obsolete, so I set it aside until I get around to switching my kernel bulids to a more modern setup.
It looks like this warning was added in the recently-released GCC 15. It's not enabled by default or with -Wall, only with -Wextra. But apparently libxcrypt was being built with -Wextra -Werror so it breaks the build.
It triggers on code like
char foo[4] = "1234";
which is perfectly legal but results in `foo` not containing a final null byte. In my experience this is usually deliberate, for cases where the array will not be used as a string and does not need the final null. But this new option in GCC 15 will
warn about it, unless marked with __attribute__((nonstring)). This attribute in turn will cause the compiler to warn if the array is ever passed to a function which is known to expect a null-terminated (str*, printf, etc)
I expect we are going to see a lot of this issue as people start building things with the new GCC.
IMHO this is an example of why -Werror is not a good idea for end-user build processes. If you want to use it in your CI to adopt GCC's nitpickiest opinions of "suspicious code" as your own coding standards, fine; but as here, it can make your source
releases gratuitously incompatible with future compilers that would otherwise work just fine for end users.
On May 10, 2025, at 12:09, yahoo <[email protected]> wrote:
Anybody else seeing this?
error: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (8 chars into 7 available) [-Werror=unterminated-string-initialization]
$ gcc --version
gcc (Gentoo Hardened 15.1.0 p55) 15.1.0
thanks,
raffaele
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)