bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#47518: 28.0.50; gcc 5.5.0 -Wstrict-overflow warning in INT_ADD_WRAPV


From: David Fussner
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

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 via email to

[Prev in Thread] Current Thread [Next in Thread]