Re: [PATCH] selftests/nolibc: avoid GCC 15 -Wunterminated-string-initialization

From: Willy Tarreau
Date: Mon Jun 23 2025 - 17:37:32 EST


On Mon, Jun 23, 2025 at 11:34:32PM +0200, Thomas Weißschuh wrote:
> On GCC 15 the following warnings is emitted:
>
> nolibc-test.c: In function 'run_stdlib':
> nolibc-test.c:1416:32: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (11 chars into 10 available) [-Wunterminated-string-initialization]
> 1416 | char buf[10] = "test123456";
> | ^~~~~~~~~~~~
>
> Increase the size of buf to avoid the warning.
>
> It would also be possible to use __attribute__((nonstring)) but that
> would require some ifdeffery to work with older compilers.

I agree with you, that's not an important enough fight to spend time
on :-)

> Fixes: 1063649cf531 ("selftests/nolibc: Add tests for strlcat() and strlcpy()")
> Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>

Acked-by: Willy Tarreau <w@xxxxxx>

willy