Hi Bruno, I was looking at the gzip CI to double check that FreeBSD was the known error "pipe-output", and it was. But I also noticed some warnings that occur on all systems that use Clang by default. Here is the steps that I used to reproduce on GNU/Linux:
$ clang --version | sed 1q clang version 20.1.3 (Fedora 20.1.3-1.fc42) $ gnulib-tool --create-testdir --dir testdir1 --single-configure c-vasnprintf $ cd testdir1 && ./configure CC='clang' CFLAGS='-Wsometimes-uninitialized' $ make [...] make[4]: Entering directory '/home/collin/.local/src/gnulib/testdir1/gllib' depbase=`echo c-vasnprintf.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ clang -DHAVE_CONFIG_H -I. -I.. -DGNULIB_STRICT_CHECKING=1 -Wsometimes-uninitialized -MT c-vasnprintf.o -MD -MP -MF $depbase.Tpo -c -o c-vasnprintf.o c-vasnprintf.c &&\ mv -f $depbase.Tpo $depbase.Po In file included from c-vasnprintf.c:46: ./vasnprintf.c:6203:49: warning: variable 'thousep_len' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] 6203 | if ((flags & FLAG_GROUP) && (intpart_digits > 1)) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./vasnprintf.c:6232:76: note: uninitialized use occurs here 6232 | p += intpart_digits + insert * thousep_len; | ^~~~~~~~~~~ ./vasnprintf.c:6203:45: note: remove the 'if' if its condition is always true 6203 | if ((flags & FLAG_GROUP) && (intpart_digits > 1)) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6204 | { [...] These warnings look correct to me since we always do "p += intpart_digits + insert * thousep_len" unconditionally without an early return. Can you confirm the attached patch is correct? Since this was introduced by your grouping fixes ~2 months ago. Collin
>From 27045298b98c7fd07c848326af3556971c48d264 Mon Sep 17 00:00:00 2001 Message-ID: <27045298b98c7fd07c848326af3556971c48d264.1748398997.git.collin.fu...@gmail.com> From: Collin Funk <collin.fu...@gmail.com> Date: Tue, 27 May 2025 19:07:10 -0700 Subject: [PATCH] vasnprintf: Fix uninitialized values. * lib/vasnprintf.c (VASNPRINFT): Initialize all occurrences of thousep_len to zero. --- ChangeLog | 6 ++++++ lib/vasnprintf.c | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index d14ec6f717..5f80f3f83d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2025-05-27 Collin Funk <collin.fu...@gmail.com> + + vasnprintf: Fix uninitialized values. + * lib/vasnprintf.c (VASNPRINFT): Initialize all occurrences of + thousep_len to zero. + 2025-05-27 Bruno Haible <br...@clisp.org> stddef-h: Make 'unreachable' usable in C++ mode. diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index a5a956603a..f46e8701bd 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -5249,7 +5249,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, const DCHAR_T *thousep = NULL; DCHAR_T thousep_buf[10]; # if !WIDE_CHAR_VERSION - size_t thousep_len; + size_t thousep_len = 0; # endif const signed char *grouping; size_t insert = 0; @@ -5579,7 +5579,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, const DCHAR_T *thousep = NULL; DCHAR_T thousep_buf[10]; # if !WIDE_CHAR_VERSION - size_t thousep_len; + size_t thousep_len = 0; # endif const signed char *grouping; size_t insert = 0; @@ -5857,7 +5857,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, const DCHAR_T *thousep = NULL; DCHAR_T thousep_buf[10]; # if !WIDE_CHAR_VERSION - size_t thousep_len; + size_t thousep_len = 0; # endif const signed char *grouping; size_t insert = 0; @@ -6195,7 +6195,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, const DCHAR_T *thousep = NULL; DCHAR_T thousep_buf[10]; # if !WIDE_CHAR_VERSION - size_t thousep_len; + size_t thousep_len = 0; # endif const signed char *grouping; size_t insert = 0; -- 2.49.0