On 1/2/21 5:49 PM, Bruno Haible wrote:
The vast majority of -Wanalyzer* warnings that we have seen so far were false
alarms [1].

I've had such bad luck with those warnings that I have not been much motivated to file GCC bug reports for them. I guess the warnings are helpful with low-quality code, but I think I've only found one bug with them in many months of using them on several GNU projects, as compared to a lot of false alarms. I'm almost tempted to disable them in Gnulib by default.

For diffutils I worked around the problem by installing the attached patch, which disables the warning in Gnulib code.

Without the attached patch I got the same warning that Jim got, when I used GCC 10.2.1 20201125 (Red Hat 10.2.1-9) x86-64. I got more warnings elsewhere in Gnulib when I used gcc (Ubuntu 10.2.0-13ubuntu1) 10.2.0 x86-64, but I'd rather not work around those bugs as we can just ask people to use --disable-gcc-warnings if their GCC is old.
From f88b033174c4fa816d3b146312820725c658f707 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Sat, 2 Jan 2021 19:07:53 -0800
Subject: [PATCH] maint: work around GCC -Wreturn-local-addr bug

* configure.ac: Do not use -Wreturn-local-addr in Gnulib,
to suppress a false alarm in vasnprintf.c.
---
 configure.ac | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/configure.ac b/configure.ac
index ef01345..3b2195e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -95,6 +95,10 @@ if test "$gl_gcc_warnings" = yes; then
   nw="$nw -Wsuggest-attribute=pure"
   nw="$nw -Wduplicated-branches"    # Too many false alarms
 
+  # Avoid false alarm in lib/vasnprintf.c.
+  # https://lists.gnu.org/r/bug-gnulib/2021-01/msg00031.html
+  gl_WARN_ADD([-Wno-analyzer-null-argument])
+
   gl_WARN_ADD([-Wno-return-local-addr])    # avoid this false alarm:
   # careadlinkat.c: In function 'careadlinkat':
   # cc1: error: function may return address of local variable [-Werror=return-local-addr]
-- 
2.27.0

Reply via email to