unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: David Fussner via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 47518@debbugs.gnu.org
Subject: bug#47518: 28.0.50; gcc 5.5.0 -Wstrict-overflow warning in INT_ADD_WRAPV
Date: Wed, 31 Mar 2021 11:12:29 +0100	[thread overview]
Message-ID: <CADF+RthX8DJtG01uR-njt=MbXq46nh5BGqX=ShyUcScm6Yk2rA@mail.gmail.com> (raw)

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





             reply	other threads:[~2021-03-31 10:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-31 10:12 David Fussner via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2021-05-08 12:08 ` bug#47518: 28.0.50; gcc 5.5.0 -Wstrict-overflow warning in INT_ADD_WRAPV Lars Ingebrigtsen
2021-05-08 12:09   ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADF+RthX8DJtG01uR-njt=MbXq46nh5BGqX=ShyUcScm6Yk2rA@mail.gmail.com' \
    --to=bug-gnu-emacs@gnu.org \
    --cc=47518@debbugs.gnu.org \
    --cc=dfussner@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).