bugmake - Bugs: bug #65537, Werrors from intprops-internal.h...

 
 

bug #65537: Werrors from intprops-internal.h with gcc 8.3.0

Submitter:  Martin Dorey <mdorey>
Submitted:  Fri 29 Mar 2024 06:14:56 PM UTC
   
 
Severity:  3 - Normal Item Group:  Build/Install
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Component Version:  SCM Operating System:  POSIX-Based
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sat 30 Mar 2024 03:35:13 AM UTC, comment #8: 

OK, I've installed that patch into Gnulib and I assume GNU Make will pick it up in due course.

Paul Eggert <eggert>
Fri 29 Mar 2024 10:36:56 PM UTC, comment #7: 

comment #6:
That change on top of t'other Paul's from #3 and without my maintMakefile change from #1 is sufficient to stop the remaining warning, thanks.
comment #5:

> GCC 4.2 and earlier doesn't support "#pragma GCC diagnostic ignored" and issues a diagnostic about it.

I see it is indeed so:

martind@stormy:~/tmp/make-65537$ cat > diagnostic-ignored.c
#pragma GCC diagnostic ignored "-Wtype-limits"
martind@stormy:~/tmp/make-65537$ gcc-4.3 -c diagnostic-ignored.c
martind@stormy:~/tmp/make-65537$ gcc-4.2 -c diagnostic-ignored.c
diagnostic-ignored.c:1: warning: unknown option after ‘#pragma GCC diagnostic’ kind
martind@stormy:~/tmp/make-65537$

... despite my not spotting any note about it in https://gcc.gnu.org/gcc-4.3/changes.html.  Apologies for my earlier failure to understand that the expression was equivalent to how I might have written it:

__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)


Martin Dorey <mdorey>
Fri 29 Mar 2024 09:58:27 PM UTC, comment #6: 

comment #4:

> In file included from lib/intprops.h:21,
>                  from src/arscan.c:379:
> src/arscan.c: In function ‘parse_int’:
> lib/intprops-internal.h:387:35: error: comparison of integer expressions of different signedness: ‘int’ and ‘uintmax_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
>           : 0 < (a) && -1 - (tmin) < (a) - 1) \
>                                    ^


This is a false alarm from old versions of GCC that suffer from GCC bug 91450. Please try the following patch to intprops-internal.h and let me know whether it works (I no longer use those old GCC versions). The patch should works without your having to fiddle with MAKE_CFLAGS. If the patch works, I can install it into Gnulib.

From cf67e37e3a9b217c83fdcae5ce883009d94b7ae8 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Fri, 29 Mar 2024 14:34:27 -0700
Subject: [PATCH] intprops: pacify GCC < 10 -Wsign-compare

Problem reported by Martin Dorey in:
https://savannah.gnu.org/bugs/index.php?65537
* lib/intprops-internal.h (_GL_INT_MULTIPLY_WRAPV):
When working around GCC bug 91450, pacify -Wsign-compare by
casting 0 to the result type.
---
 ChangeLog               | 9 +++++++++
 lib/intprops-internal.h | 4 +++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 931322915b..f967275871 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-03-29  Paul Eggert  <eggert@cs.ucla.edu>
+
+        intprops: pacify GCC < 10 -Wsign-compare
+        Problem reported by Martin Dorey in:
+        https://savannah.gnu.org/bugs/index.php?65537
+        * lib/intprops-internal.h (_GL_INT_MULTIPLY_WRAPV):
+        When working around GCC bug 91450, pacify -Wsign-compare by
+        casting 0 to the result type.
+
 2024-03-29  Collin Funk  <collin.funk1@gmail.com>

         gnulib-tool.py: Display specified modules in bold.
diff --git a/lib/intprops-internal.h b/lib/intprops-internal.h
index c8a87d2bb2..b5ba8d7cbd 100644
--- a/lib/intprops-internal.h
+++ b/lib/intprops-internal.h
@@ -169,7 +169,9 @@
    /* Work around GCC bug 91450.  */
 #  define _GL_INT_MULTIPLY_WRAPV(a, b, r) \
     ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && _GL_EXPR_SIGNED (a) && _GL_EXPR_SIGNED (b) \
-      && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \
+      && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, \
+                                          (__typeof__ (*(r))) 0, \
+                                          (__typeof__ (*(r))) -1)) \
      ? ((void) __builtin_mul_overflow (a, b, r), 1) \
      : __builtin_mul_overflow (a, b, r))
 # endif
--
2.44.0


Paul Eggert <eggert>
Fri 29 Mar 2024 09:50:10 PM UTC, comment #5: 

original submission:

> I don't understand the macro guard there.  Why would Paul Eggert want to avoid using the pragma in the half-open region between gcc 4.4 and gcc 5, while using it for the half-open region from gcc 4.0 to gcc 4.4?


If you're talking about this code:

/* Pacify GCC 13.2 in some calls to _GL_EXPR_SIGNED.  */
#if defined __GNUC__ && 4 < __GNUC__ + (3 <= __GNUC_MINOR__)
# pragma GCC diagnostic ignored "-Wtype-limits"
#endif


This uses the pragma in GCC 4.3 and later because GCC 4.2 and earlier doesn't support "#pragma GCC diagnostic ignored" and issues a diagnostic about it.

With the above code in place, you shouldn't need to put -Wno-error=type-limits into MAKE_CFLAGS. If you're still getting a diagnostic with the above code in place and with MAKE_CFLAGS unchanged from Git, please investigate why the above code doesn't suppress -Wtype-limits.

Paul Eggert <eggert>
Fri 29 Mar 2024 07:05:51 PM UTC, comment #4: 

I made that change, then, not knowing how to activate it, just tried running bootstrap again.  That failed the same way I saw, but didn't report, earlier today, somehow clobbering the gnulib that had been cloned before, causing a second run of bootstrap to clone the desired version:

martind@stormy:~/download/make-2024-03-29$ ./bootstrap
./bootstrap: Bootstrapping from checked-out make sources...
error: pathspec 'stable-202401' did not match any file(s) known to git
martind@stormy:~/download/make-2024-03-29$ ./bootstrap
./bootstrap: Bootstrapping from checked-out make sources...
./bootstrap: getting gnulib files...
Initialized empty Git repository in /home/martind/download/make-2024-03-29/gnulib/.git/
remote: Counting objects: 11218, done.
remote: Compressing objects: 100% (10014/10014), done.
remote: Total 11218 (delta 5569), reused 2561 (delta 1185)
Receiving objects: 100% (11218/11218), 10.25 MiB | 5.92 MiB/s, done.
Resolving deltas: 100% (5569/5569), done.
From https://git.savannah.gnu.org/git/gnulib
 * branch            stable-202401 -> FETCH_HEAD
 * [new branch]      stable-202401 -> origin/stable-202401
HEAD is now at 2fccdc0 gettime-res: Fix test failure on Solaris 11.4/SPARC.
Branch 'stable-202401' set up to track remote branch 'stable-202401' from 'origin'.
Switched to a new branch 'stable-202401'
...

As might be expected from the previously queried change for disabling the type-limits warning for gcc >= 5, a threshold that seems somewhat unlikely to have been deliberate, I'm left with just the sign-compare one:

mv -f $depbase.Tpo $depbase.Po
In file included from lib/intprops.h:21,
                 from src/arscan.c:379:
src/arscan.c: In function ‘parse_int’:
lib/intprops-internal.h:387:35: error: comparison of integer expressions of different signedness: ‘int’ and ‘uintmax_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
          : 0 < (a) && -1 - (tmin) < (a) - 1) \
                                   ^
lib/intprops-internal.h:172:10: note: in expansion of macro ‘_GL_INT_MULTIPLY_RANGE_OVERFLOW’
       && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/intprops.h:302:37: note: in expansion of macro ‘_GL_INT_MULTIPLY_WRAPV’
 #define INT_MULTIPLY_WRAPV(a, b, r) _GL_INT_MULTIPLY_WRAPV (a, b, r)
                                     ^~~~~~~~~~~~~~~~~~~~~~
src/arscan.c:399:14: note: in expansion of macro ‘INT_MULTIPLY_WRAPV’
           || INT_MULTIPLY_WRAPV (val, base, &val)
              ^~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:897: src/arscan.o] Error 1


Martin Dorey <mdorey>
Fri 29 Mar 2024 06:43:39 PM UTC, comment #3: 

I see there's a new stable branch: either these are not getting announced or I missed it.

Can you try applying this patch and switching to this stable branch and see if it is fixed:

diff --git a/bootstrap.conf b/bootstrap.conf
index 98a709a5..871bdb09 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -19,7 +19,7 @@
 checkout_only_file=README.git

 # Choose a specific version of gnulib, when checking out
-GNULIB_REVISION=stable-202307
+GNULIB_REVISION=stable-202401

 # Always copy files rather than symlink
 copy=true


Paul D. Smith <psmith>
Group administrator
Fri 29 Mar 2024 06:33:32 PM UTC, comment #2: 


> Are you using the latest HEAD of the stable-202307 branch of gnulib?

I'm using whatever Gnu Make cloned for me.

> It should be SHA 2f47ff2e115712

I do indeed see that substring in:

martind@stormy:~/download/make-2024-03-29/gnulib$ git log -n 1
commit 2f47ff2e1157125c4e07828e8f11c3fe07ee29a1 (HEAD -> stable-202307, origin/stable-202307, master)
Author: Bruno Haible <bruno@clisp.org>
Date:   Tue Mar 26 12:12:23 2024 +0100

    gettime-res: Fix test failure on Solaris 11.4/SPARC.

    * lib/gettime-res.c (gettime_res): On Solaris/SPARC, just return 1 ns.
martind@stormy:~/download/make-2024-03-29/gnulib$

I don't see this problem on a Debian 11/Bullsye system which reports:

gcc version 10.2.1 20210110 (Debian 10.2.1-6)


Martin Dorey <mdorey>
Fri 29 Mar 2024 06:24:10 PM UTC, comment #1: 

This is an issue with gnulib, not GNU Make, where that macro is defined.

Are you using the latest HEAD of the stable-202307 branch of gnulib?  It should be SHA 2f47ff2e115712

If so then we need to discuss on the gnulib mailing list.

Paul D. Smith <psmith>
Group administrator
Fri 29 Mar 2024 06:14:56 PM UTC, original submission:  

A fresh git clone of Gnu Make fails to build for me on Debian 10/Buster with:

mv -f $depbase.Tpo $depbase.Po
In file included from lib/intprops.h:21,
                 from src/arscan.c:379:
src/arscan.c: In function ‘parse_int’:
lib/intprops-internal.h:39:59: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
 #define _GL_EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
                                                           ^
lib/intprops-internal.h:166:42: note: in expansion of macro ‘_GL_EXPR_SIGNED’
     ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && _GL_EXPR_SIGNED (a) && _GL_EXPR_SIGNED (b) \
                                          ^~~~~~~~~~~~~~~
lib/intprops.h:302:37: note: in expansion of macro ‘_GL_INT_MULTIPLY_WRAPV’
 #define INT_MULTIPLY_WRAPV(a, b, r) _GL_INT_MULTIPLY_WRAPV (a, b, r)
                                     ^~~~~~~~~~~~~~~~~~~~~~
src/arscan.c:399:14: note: in expansion of macro ‘INT_MULTIPLY_WRAPV’
           || INT_MULTIPLY_WRAPV (val, base, &val)
              ^~~~~~~~~~~~~~~~~~
lib/intprops-internal.h:372:11: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
    ? ((a) < 0 \
           ^
lib/intprops-internal.h:167:10: note: in expansion of macro ‘_GL_INT_MULTIPLY_RANGE_OVERFLOW’
       && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/intprops.h:302:37: note: in expansion of macro ‘_GL_INT_MULTIPLY_WRAPV’
 #define INT_MULTIPLY_WRAPV(a, b, r) _GL_INT_MULTIPLY_WRAPV (a, b, r)
                                     ^~~~~~~~~~~~~~~~~~~~~~
src/arscan.c:399:14: note: in expansion of macro ‘INT_MULTIPLY_WRAPV’
           || INT_MULTIPLY_WRAPV (val, base, &val)
              ^~~~~~~~~~~~~~~~~~
lib/intprops-internal.h:39:59: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
 #define _GL_EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
                                                           ^
lib/intprops-internal.h:373:10: note: in expansion of macro ‘_GL_EXPR_SIGNED’
       ? (_GL_EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \
          ^~~~~~~~~~~~~~~
lib/intprops-internal.h:167:10: note: in expansion of macro ‘_GL_INT_MULTIPLY_RANGE_OVERFLOW’
       && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/intprops.h:302:37: note: in expansion of macro ‘_GL_INT_MULTIPLY_WRAPV’
 #define INT_MULTIPLY_WRAPV(a, b, r) _GL_INT_MULTIPLY_WRAPV (a, b, r)
                                     ^~~~~~~~~~~~~~~~~~~~~~
src/arscan.c:399:14: note: in expansion of macro ‘INT_MULTIPLY_WRAPV’
           || INT_MULTIPLY_WRAPV (val, base, &val)
              ^~~~~~~~~~~~~~~~~~
lib/intprops-internal.h:39:59: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
 #define _GL_EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
                                                           ^
lib/intprops-internal.h:380:10: note: in expansion of macro ‘_GL_EXPR_SIGNED’
       ? (_GL_EXPR_SIGNED (a) \
          ^~~~~~~~~~~~~~~
lib/intprops-internal.h:167:10: note: in expansion of macro ‘_GL_INT_MULTIPLY_RANGE_OVERFLOW’
       && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/intprops.h:302:37: note: in expansion of macro ‘_GL_INT_MULTIPLY_WRAPV’
 #define INT_MULTIPLY_WRAPV(a, b, r) _GL_INT_MULTIPLY_WRAPV (a, b, r)
                                     ^~~~~~~~~~~~~~~~~~~~~~
src/arscan.c:399:14: note: in expansion of macro ‘INT_MULTIPLY_WRAPV’
           || INT_MULTIPLY_WRAPV (val, base, &val)
              ^~~~~~~~~~~~~~~~~~
lib/intprops-internal.h:382:35: error: comparison of integer expressions of different signedness: ‘int’ and ‘uintmax_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
          : 0 < (a) && -1 - (tmin) < (a) - 1) \
                                   ^
lib/intprops-internal.h:167:10: note: in expansion of macro ‘_GL_INT_MULTIPLY_RANGE_OVERFLOW’
       && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/intprops.h:302:37: note: in expansion of macro ‘_GL_INT_MULTIPLY_WRAPV’
 #define INT_MULTIPLY_WRAPV(a, b, r) _GL_INT_MULTIPLY_WRAPV (a, b, r)
                                     ^~~~~~~~~~~~~~~~~~~~~~
src/arscan.c:399:14: note: in expansion of macro ‘INT_MULTIPLY_WRAPV’
           || INT_MULTIPLY_WRAPV (val, base, &val)
              ^~~~~~~~~~~~~~~~~~
lib/intprops-internal.h:386:11: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
    : ((a) < 0 \
           ^
lib/intprops-internal.h:167:10: note: in expansion of macro ‘_GL_INT_MULTIPLY_RANGE_OVERFLOW’
       && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/intprops.h:302:37: note: in expansion of macro ‘_GL_INT_MULTIPLY_WRAPV’
 #define INT_MULTIPLY_WRAPV(a, b, r) _GL_INT_MULTIPLY_WRAPV (a, b, r)
                                     ^~~~~~~~~~~~~~~~~~~~~~
src/arscan.c:399:14: note: in expansion of macro ‘INT_MULTIPLY_WRAPV’
           || INT_MULTIPLY_WRAPV (val, base, &val)
              ^~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:896: src/arscan.o] Error 1
make[1]: Leaving directory '/home/martind/download/make-2024-03-29'
make: *** [Makefile:982: all-recursive] Error 1
martind@stormy:~/download/make-2024-03-29$

I'm not seriously suggesting it but, having found some mail from over a decade ago at https://bug-gnulib.gnu.narkive.com/IJgonyeq/test-intprops-c-many-new-warnings suggesting ignoring the warnings here, I unblocked myself with:

--- a/maintMakefile
+++ b/maintMakefile
@@ -32,6 +32,7 @@ PERLFLAGS := -w
 MAKE_CFLAGS := -C -Wall -Wextra -Werror -Wwrite-strings -Wshadow \
        -Wdeclaration-after-statement -Wbad-function-cast -Wformat-security \
        -Wtype-limits -Wunused-but-set-parameter -Wlogical-op -Wpointer-arith \
+       -Wno-error=type-limits -Wno-error=sign-compare \
        -Wignored-qualifiers -Wformat-signedness -Wduplicated-cond

 AM_CFLAGS += $(MAKE_CFLAGS)

I see there's https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=4d38340a76dbee56036a5fcc0f052ebcff616a59 upstream, though not in Gnu Make.  I don't understand the macro guard there.  Why would Paul Eggert want to avoid using the pragma in the half-open region between gcc 4.4 and gcc 5, while using it for the half-open region from gcc 4.0 to gcc 4.4?  I wondered if it was to do with when support for disabling warnings was added, but failed to chase down when that was.  The comment mentions a version after 13.2 changing behavior, so I wonder if he intended a change from 13.3 on, which could be expressed as 14 <= _GNUC_ + (3 <= _GNUC_MINOR_), which is only two characters different from what was committed.

Martin Dorey <mdorey>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by eggert (Posted a comment)
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by mdorey (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code