The coreutils patch installed on May 10 to pacify GCC 10 -fanalyzer
caused problems when I built coreutils with GCC 10.1.0. Some of the
newly-introduced pragmas generated diagnostics, and the pragmas didn't
seem to be needed in GCC 10.1.0 anyway. As 10.1.0 is the first public
release of GCC 10 I doubt whether we need to support GCC internal
versions (before GCC 10.1.0) that had problems with -fanalyze.
Also, the patch seems to have introduced a bug in tsort.c due to a typo.
Less importantly, it introduced some new overhead in dd.c's non-lint
code (to save some pointers in global variables) that isn't needed and
might cause problems with other static checkers.
To try to fix all this I installed the attached patches.
At some point I hope this GCC 10 stuff settles down, as GCC 10.1.0 still
has bugs in the -fanalyzer area (e.g., see GCC bugs 93644, 95044, 95072)
and we don't want these bugs to adversely affect coreutils etc.
>From e18efcfd0422b892ddd165035bad4f241591aa17 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Wed, 20 May 2020 16:40:26 -0700
Subject: [PATCH 1/2] maint: omit unnecessary pragmas and fix tsort.c
* src/chown-core.c, src/comm.c:
* src/tsort.c (record_relation):
Remove GCC 10 pragmas that are not needed in GCC 10.1.0 (the first
public GCC 10 release) and that in some cases cause diagnostics
with GCC 10.1.0. The tsort.c change fixes a bug that was
inadvertantly introduced when these pragmas were added.
---
src/chown-core.c | 5 -----
src/comm.c | 5 -----
src/tsort.c | 8 --------
3 files changed, 18 deletions(-)
diff --git a/src/chown-core.c b/src/chown-core.c
index 6c221d287..f1e37eb26 100644
--- a/src/chown-core.c
+++ b/src/chown-core.c
@@ -16,11 +16,6 @@
/* Extracted from chown.c/chgrp.c and librarified by Jim Meyering. */
-/* GCC 10 gives a false postive warning with -fanalyzer for this. */
-#if (__GNUC__ == 10 && 0 <= __GNUC_MINOR__) || 10 < __GNUC__
-# pragma GCC diagnostic ignored "-Wanalyzer-double-free"
-#endif
-
#include <config.h>
#include <stdio.h>
#include <sys/types.h>
diff --git a/src/comm.c b/src/comm.c
index 826023c34..2bf8094bf 100644
--- a/src/comm.c
+++ b/src/comm.c
@@ -16,11 +16,6 @@
/* Written by Richard Stallman and David MacKenzie. */
-/* GCC 10 gives a false postive warning with -fanalyzer for this. */
-#if (__GNUC__ == 10 && 0 <= __GNUC_MINOR__) || 10 < __GNUC__
-# pragma GCC diagnostic ignored "-Wanalyzer-use-of-uninitialized-value"
-#endif
-
#include <config.h>
#include <getopt.h>
diff --git a/src/tsort.c b/src/tsort.c
index cff2d3a65..2a6961aa7 100644
--- a/src/tsort.c
+++ b/src/tsort.c
@@ -274,12 +274,6 @@ record_relation (struct item *j, struct item *k)
{
struct successor *p;
-/* GCC 10 gives a false postive warning with -fanalyzer for this,
- and an assert did not suppress the warning
- with the initial GCC 10 release. */
-#if (__GNUC__ == 10 && 0 <= __GNUC_MINOR__) || 10 < __GNUC__
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wanalyzer-null-dereference"
if (!STREQ (j->str, k->str))
{
k->count++;
@@ -288,8 +282,6 @@ record_relation (struct item *j, struct item *k)
p->next = j->top;
j->top = p;
}
-# pragma GCC diagnostic pop
-#endif
}
static bool
--
2.25.4
>From dc7aac9c7e799329a84d571de98d7f0e4ad81c36 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Wed, 20 May 2020 16:47:49 -0700
Subject: [PATCH 2/2] dd: omit unnecessary vars when !lint
* src/dd.c (real_ibuf, real_obuf) [!lint]:
Remove, as they're needed only when lint checking.
All uses removed when 'lint' is not defined.
---
src/dd.c | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/src/dd.c b/src/dd.c
index 2ce9e4935..4b0cddc9d 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -242,14 +242,14 @@ static uintmax_t r_truncate = 0;
static char newline_character = '\n';
static char space_character = ' ';
-/* Input buffer. */
+#ifdef lint
+/* Memory blocks allocated for I/O buffers and surrounding areas. */
static char *real_ibuf;
-/* aligned offset into the above. */
-static char *ibuf;
-
-/* Output buffer. */
static char *real_obuf;
-/* aligned offset into the above. */
+#endif
+
+/* I/O buffers. */
+static char *ibuf;
static char *obuf;
/* Current index into 'obuf'. */
@@ -697,8 +697,8 @@ alloc_ibuf (void)
if (ibuf)
return;
- real_ibuf = malloc (input_blocksize + INPUT_BLOCK_SLOP);
- if (!real_ibuf)
+ char *buf = malloc (input_blocksize + INPUT_BLOCK_SLOP);
+ if (!buf)
{
uintmax_t ibs = input_blocksize;
char hbuf[LONGEST_HUMAN_READABLE + 1];
@@ -708,8 +708,10 @@ alloc_ibuf (void)
human_readable (input_blocksize, hbuf,
human_opts | human_base_1024, 1, 1));
}
-
- ibuf = ptr_align (real_ibuf + SWAB_ALIGN_OFFSET, page_size);
+#ifdef lint
+ real_ibuf = buf;
+#endif
+ ibuf = ptr_align (buf + SWAB_ALIGN_OFFSET, page_size);
}
/* Ensure output buffer OBUF is allocated/initialized. */
@@ -723,8 +725,8 @@ alloc_obuf (void)
if (conversions_mask & C_TWOBUFS)
{
/* Page-align the output buffer, too. */
- real_obuf = malloc (output_blocksize + OUTPUT_BLOCK_SLOP);
- if (!real_obuf)
+ char *buf = malloc (output_blocksize + OUTPUT_BLOCK_SLOP);
+ if (!buf)
{
uintmax_t obs = output_blocksize;
char hbuf[LONGEST_HUMAN_READABLE + 1];
@@ -735,7 +737,10 @@ alloc_obuf (void)
human_readable (output_blocksize, hbuf,
human_opts | human_base_1024, 1, 1));
}
- obuf = ptr_align (real_obuf, page_size);
+#ifdef lint
+ real_obuf = buf;
+#endif
+ obuf = ptr_align (buf, page_size);
}
else
{
--
2.25.4