On 14/03/2023 13:55, Marcus Müller wrote:
Dear Gnulib community,

On Linux, x86_64, Fedora 37, ran, on today's coreutils' HEAD (e68b15), which 
submodule-includes gnulib f17d3977:

CFLAGS=-Wno-deprecated-declarations ./configure

(as that CFLAGS is necessary, otherwise sha will fail to build due to using 
deprecated functionality; no big issue).
However, building coreutils fails in gnulib and that does seem to be a 
significant bug:

make -j8 fails with

lib/nstrftime.c: In function '__strftime_internal':
lib/nstrftime.c:147:31: error: 'memset' specified size 18446744073709551615 
exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]

This is triggered by -O2 being implicitly removed when you specified the CFLAGS 
explicitly.
I.e. there are gcc false positives at lower optimization levels.

Also you're building from git, and so will have more strict
developer appropriate warning settings by default
(which can be controlled with the --enable-gcc-warnings=no configure option).

In my experience of this particular "stringop-overflow" warning,
I've had to work around it so many times in a large build system in work
that I disabled it by default in the central build config.
It probably makes sense to disable this in the coreutils settings at least,
which is done in the attached.
The attached also addresses -Wmaybe-initialized warnings in coreutils
that show up at lower optimization levels.

cheers,
Pádraig
diff --git a/configure.ac b/configure.ac
index 2b2f9468d..f33c10ccc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -262,6 +262,10 @@ if test $gl_gcc_warnings != no; then
   # FP in careadlinkat.c w/gcc 10.0.1 20200205
   gl_WARN_ADD([-Wno-return-local-addr])
 
+  # FIXME: remove this line when gcc -O0 improves
+  # FP in nstrftime.c w/gcc 12.2.1 20221121
+  gl_WARN_ADD([-Wno-stringop-overflow])
+
   gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
   AC_SUBST([GNULIB_WARN_CFLAGS])
 
diff --git a/src/digest.c b/src/digest.c
index 6ee8a4854..3c1d27f9a 100644
--- a/src/digest.c
+++ b/src/digest.c
@@ -1125,6 +1125,7 @@ hex_equal (unsigned char const *hex_digest, unsigned char const *bin_buffer)
   return cnt == digest_bin_bytes;
 }
 
+# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
 static bool
 digest_check (char const *checkfile_name)
 {
diff --git a/src/pr.c b/src/pr.c
index 28a695242..75ce756ae 100644
--- a/src/pr.c
+++ b/src/pr.c
@@ -2422,7 +2422,7 @@ static bool
 read_line (COLUMN *p)
 {
   int c;
-  int chars;
+  int chars=0;
   int last_input_position;
   int j, k;
   COLUMN *q;
diff --git a/src/sort.c b/src/sort.c
index 8ca7a88c4..15f06e7d8 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -1045,7 +1045,7 @@ pipe_fork (int pipefds[2], size_t tries)
   struct tempnode *saved_temphead;
   int saved_errno;
   double wait_retry = 0.25;
-  pid_t pid;
+  pid_t pid = -1;
   struct cs_status cs;
 
   if (pipe2 (pipefds, O_CLOEXEC) < 0)

Reply via email to