GNU bug report logs - #47518
28.0.50; gcc 5.5.0 -Wstrict-overflow warning in INT_ADD_WRAPV

Previous Next

Package: emacs;

Reported by: David Fussner <dfussner <at> googlemail.com>

Date: Wed, 31 Mar 2021 10:15:01 UTC

Severity: minor

Tags: wontfix

Found in version 28.0.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 47518 in the body.
You can then email your comments to 47518 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#47518; Package emacs. (Wed, 31 Mar 2021 10:15:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to David Fussner <dfussner <at> googlemail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 31 Mar 2021 10:15:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: David Fussner <dfussner <at> googlemail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; gcc 5.5.0 -Wstrict-overflow warning in INT_ADD_WRAPV
Date: Wed, 31 Mar 2021 11:12:29 +0100
Since late December, when compiling master with gcc 5.5.0 on a 32-bit
Slackware install I see multiple warnings like the following.  _All_
of the messages involve INT_ADD_WRAPV:

In file included from dispnew.c:27:0:
lisp.h: In function 'modiff_incr':
lisp.h:3505:3: warning: assuming signed overflow does not occur when
assuming that (X + c) > X is always true [-Wstrict-overflow]
   bool modiff_overflow = INT_ADD_WRAPV (a0, 1, a);
   ^
(This last from every .c file that includes lisp.h.)

Slightly more informatively:

In file included from lisp.h:34:0,
                 from casefiddle.c:25:
casefiddle.c: In function 'do_casify_multibyte_string':
casefiddle.c:276:43: warning: assuming signed overflow does not occur
when assuming that (X + c) > X is always true [-Wstrict-overflow]
       || INT_ADD_WRAPV (n, sizeof (struct casing_str_buf), &n))
                                           ^
../lib/intprops.h:556:30: note: in definition of macro
'_GL_INT_ADD_RANGE_OVERFLOW'
           && (a) < (tmin) - (b)) \
                              ^
../lib/intprops.h:505:11: note: in expansion of macro '_GL_INT_OP_CALC'
         ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
           ^
../lib/intprops.h:495:7: note: in expansion of macro '_GL_INT_OP_WRAPV_LONGISH'
     : _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow))
       ^
../lib/intprops.h:387:4: note: in expansion of macro '_GL_INT_OP_WRAPV'
    _GL_INT_OP_WRAPV (a, b, r, +, _GL_INT_ADD_RANGE_OVERFLOW)
    ^
casefiddle.c:276:10: note: in expansion of macro 'INT_ADD_WRAPV'
       || INT_ADD_WRAPV (n, sizeof (struct casing_str_buf), &n))
          ^

In the gnulib updates from 24/12/2020, commit 29064d02c31, there's this
change to lib/intprops.h:231

 /* True if __builtin_add_overflow (A, B, P) and __builtin_sub_overflow
    (A, B, P) work when P is non-null.  */
-#if 5 <= __GNUC__ && !defined __ICC
+/* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x,
+   see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269>.  */
+#if 7 <= __GNUC__ && !defined __ICC
 # define _GL_HAS_BUILTIN_ADD_OVERFLOW 1
 #elif defined __has_builtin
 # define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow)

Reverting this hunk makes the messages go away. From this I conclude
that the non-builtin version of INT_ADD_WRAPV triggers the warnings,
but staring at the code left me no wiser. I assume that someone using
a more up-to-date compiler could simply change the 7 in that hunk to
15 in order to force use of the non-builtin version to reproduce this,
but I haven't a system upon which to try it, and since
-Wstrict-overflow behavior may have changed since version 5 I'm not
sure this will work anyway. I turned off the warnings in
m4/manywarnings.m4 in my local copy and promptly forgot about it
(hence the delay before reporting it), so if this really is spurious
then a patch like:

diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4
index c3ac28752b..7f8f6f8080 100644
--- a/m4/manywarnings.m4
+++ b/m4/manywarnings.m4
@@ -184,6 +184,11 @@ AC_DEFUN
         gl_AS_VAR_APPEND([$1], [' -funit-at-a-time'])
           ;;
     esac
+    case `($CC --version) 2>/dev/null` in
+      'gcc (GCC) '[[5-6]].*.*)
+        gl_AS_VAR_APPEND([$1], [' -Wno-strict-overflow'])
+          ;;
+    esac
   fi

   # Disable specific options as needed.

works for me (perhaps with more gcc versions included?).

I have a complete log of the error messages from the build if that
would be useful.

Many thanks,

David.

In GNU Emacs 28.0.50 (build 13, i686-pc-linux-gnu, GTK+ Version
3.18.9, cairo version 1.14.6)
 of 2021-03-30 built on newfont
Repository revision: 4bfcfdb41638f37c89c0db8f297707773c677656
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.11803000
System Description: Slackware 14.2

Configured using:
 'configure
 PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB

Important settings:
  value of $LC_COLLATE: C
  value of $LANG: en_US.ISO8859-1
  locale-coding-system: iso-latin-1-unix




Severity set to 'minor' from 'normal' Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Wed, 21 Apr 2021 00:18:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47518; Package emacs. (Sat, 08 May 2021 12:09:02 GMT) Full text and rfc822 format available.

Message #10 received at 47518 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: David Fussner <dfussner <at> googlemail.com>
Cc: 47518 <at> debbugs.gnu.org
Subject: Re: bug#47518: 28.0.50; gcc 5.5.0 -Wstrict-overflow warning in
 INT_ADD_WRAPV
Date: Sat, 08 May 2021 14:08:26 +0200
David Fussner <dfussner <at> googlemail.com> writes:

> Since late December, when compiling master with gcc 5.5.0 on a 32-bit
> Slackware install I see multiple warnings like the following.  _All_
> of the messages involve INT_ADD_WRAPV:
>
> In file included from dispnew.c:27:0:
> lisp.h: In function 'modiff_incr':
> lisp.h:3505:3: warning: assuming signed overflow does not occur when
> assuming that (X + c) > X is always true [-Wstrict-overflow]
>    bool modiff_overflow = INT_ADD_WRAPV (a0, 1, a);
>    ^
> (This last from every .c file that includes lisp.h.)

It's to be expected to get warnings in older gcc versions for a variety
of things -- and gcc 5.5.0 is five years old.  We don't have a strict
policy for this in Emacs, but it's been common to disregard warnings
from gcc versions that are a few years old.

So I'm closing this bug report.  If somebody thinks that this is
something that should be worked on, please respond to the debbugs
address and we'll reopen.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) wontfix. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 08 May 2021 12:09:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 47518 <at> debbugs.gnu.org and David Fussner <dfussner <at> googlemail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 08 May 2021 12:09:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47518; Package emacs. (Sat, 08 May 2021 12:11:02 GMT) Full text and rfc822 format available.

Message #17 received at 47518 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: David Fussner <dfussner <at> googlemail.com>
Cc: 47518 <at> debbugs.gnu.org
Subject: Re: bug#47518: 28.0.50; gcc 5.5.0 -Wstrict-overflow warning in
 INT_ADD_WRAPV
Date: Sat, 08 May 2021 14:09:50 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> gcc 5.5.0 is five years old.

(Four years old -- off-by-one error.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 06 Jun 2021 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 315 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.