I tried to build coreutils with warnings enabled and using the latest gcc (built from head of gcc.git) and was irritated to see it fail with a few of the new warnings evoking apparent false positives, like these:
lib/human.c: In function 'human_readable': lib/human.c:232:24: error: '%.0Lf' directive output between 1 and 4934 \ bytes may exceed minimum required size of 4095 [-Werror=format-overflow=] sprintf (buf, "%.0Lf", adjust_value (inexact_style, damt)); parse-datetime.y:1626:33: error: ' TZ=' directive output truncated writing \ 4 bytes into a region of size 1 [-Werror=format-truncation=] parse-datetime.y:1626:33: note: assuming directive output of 1 byte In file included from /usr/include/stdio.h:939:0, from ./lib/stdio.h:43, from parse-datetime.y:68: /usr/include/bits/stdio2.h:64:10: note: '__builtin___snprintf_chk' output 5 \ or more bytes (assuming 6) into a destination of size 1 return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ __bos (__s), __fmt, __va_arg_pack ()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Hoping they'd been addressed in latest gnulib, I tried updating the submodule, but with that, even bootstrap failed due to inability to apply coreutils' gl/modules/tempname.diff patch. I adjusted that .diff file and upgraded gnulib to latest in the first patch below, but the warning/error issues persisted, so I disabled the offenders via the second patch. Now, "make distcheck" nearly completes. I'll push these soon if no one objects. >From 0b7fababf893803505e0382f71dc755951c98cc8 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@fb.com> Date: Fri, 11 Aug 2017 17:33:15 -0700 Subject: [PATCH 1/2] gnulib: update to latest and adjust gl/modules/tempname.diff * gnulib: Update to latest. * gl/modules/tempname.diff: This patch failed to apply. Adjust it to reflect removal of the secure_getenv dependency. --- gl/modules/tempname.diff | 3 +-- gnulib | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/gl/modules/tempname.diff b/gl/modules/tempname.diff index 4aee47c6f..d572734b6 100644 --- a/gl/modules/tempname.diff +++ b/gl/modules/tempname.diff @@ -2,12 +2,11 @@ diff --git a/modules/tempname b/modules/tempname index 570ea54..f1be8ff 100644 --- a/modules/tempname +++ b/modules/tempname -@@ -12,7 +12,9 @@ extensions +@@ -12,6 +12,8 @@ fcntl-h gettimeofday lstat +randint - secure_getenv +stdbool stdint sys_stat diff --git a/gnulib b/gnulib index ac2fdcad6..0474f8e6a 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit ac2fdcad666d24d51a32a152fe1b3911b610344d +Subproject commit 0474f8e6a85621c276dfc47099b9863a47f96a0d -- 2.14.1.145.gb3622a4ee >From 96101eef33b2a56bd169560cd806b4b3237d2430 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@fb.com> Date: Sat, 12 Aug 2017 13:51:19 -0700 Subject: [PATCH 2/2] build: adjust warning options to work with latest GCC * configure.ac: Disable some new warnings to avoid false positives. Building with warnings enabled and latest gcc would evoke build failure without these changes. Disable the following in coreutils proper: -Wformat-overflow=2 -Wformat-truncation=2, and disable these for gnulib: -Wformat-truncation=2 -Wduplicated-branches --- configure.ac | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac index 7c7c8c238..73e445d02 100644 --- a/configure.ac +++ b/configure.ac @@ -133,6 +133,8 @@ if test "$gl_gcc_warnings" = yes; then nw="$nw -Wswitch-default" # Too many warnings for now nw="$nw -Wstack-protector" # not worth working around nw="$nw -Wtype-limits" # False alarms for portable code + nw="$nw -Wformat-overflow=2" # False alarms due to GCC bug 80776 + nw="$nw -Wformat-truncation=2" # False alarm in ls.c, probably related # things I might fix soon: nw="$nw -Wfloat-equal" # sort.c, seq.c nw="$nw -Wmissing-format-attribute" # copy.c @@ -193,6 +195,8 @@ if test "$gl_gcc_warnings" = yes; then # We use a slightly smaller set of warning options for lib/. # Remove the following and save the result in GNULIB_WARN_CFLAGS. nw= + nw="$nw -Wduplicated-branches" # Too many false alarms + nw="$nw -Wformat-truncation=2" nw="$nw -Wstrict-overflow" nw="$nw -Wuninitialized" nw="$nw -Wunused-macros" -- 2.14.1.145.gb3622a4ee