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

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: minor; Reported by: David Fussner <dfussner@HIDDEN>; dated Wed, 31 Mar 2021 10:15:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Severity set to 'minor' from 'normal' Request was from Stefan Kangas <stefan@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 31 Mar 2021 10:14:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 31 06:14:44 2021
Received: from localhost ([127.0.0.1]:53513 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lRXs3-000435-Ok
	for submit <at> debbugs.gnu.org; Wed, 31 Mar 2021 06:14:44 -0400
Received: from lists.gnu.org ([209.51.188.17]:48796)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dfussner@HIDDEN>) id 1lRXs0-00042w-Dl
 for submit <at> debbugs.gnu.org; Wed, 31 Mar 2021 06:14:43 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:56576)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <dfussner@HIDDEN>)
 id 1lRXs0-00041v-6M
 for bug-gnu-emacs@HIDDEN; Wed, 31 Mar 2021 06:14:40 -0400
Received: from mail-qk1-x729.google.com ([2607:f8b0:4864:20::729]:46706)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <dfussner@HIDDEN>)
 id 1lRXrw-0006JE-PW
 for bug-gnu-emacs@HIDDEN; Wed, 31 Mar 2021 06:14:39 -0400
Received: by mail-qk1-x729.google.com with SMTP id z10so18744709qkz.13
 for <bug-gnu-emacs@HIDDEN>; Wed, 31 Mar 2021 03:14:35 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=googlemail.com; s=20161025;
 h=mime-version:from:date:message-id:subject:to;
 bh=3A0ur1erXvjFDLKO0qEy8VmnT4+pct5uVWVAv74cK2s=;
 b=VJPSnbnHpIJvCf874s4uV1xpspdyHMBWQPLpvm2ahhtB5YbDbcj0TL5OO/MNxTqi3W
 31FYte+2oZKvJAH0JR64BlYka54R2+aKD6vVjEfqAcAyZzCxUsnwiQN+jO8EtJrhxZaG
 iZm7TMAVHpzqmzvPdVzf++LezDADoBKdbgwqVLkBME7BzUq74DadjvgWDAm2lC6CC5hq
 ChTzBeOUmDyqjd8O5NkPtfOv3S/amyNFv6la0Lq8H519KVQqXXJphnRKDzXebbhGvWOj
 bhXgiqRDGxgcQWNMWQF9c3ghK1er5v4h5MUOriSBnHItyG+oy9+WsqRga+2TRIpGgQeu
 4I0w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=3A0ur1erXvjFDLKO0qEy8VmnT4+pct5uVWVAv74cK2s=;
 b=j7bv3bv4MSXSFe92zAnM0Wl2IzTzkSGSLfS/GDLtrPMPwHtpMdET0RTZVI6+9usJpx
 yTS29EzR96kZIOwdaocMd8txonlNjq7EEMxP09GOXa5uMt4PRSg9eDIkDjouIbLtlIGg
 BMd5693GFsS7Jg82zBk6jv83AihZOFsNrLCV9NWI1tW8fCDNzzHFTev3cIWtXZC/VvGy
 iq2K/r8TX2DfnVD//NoEyehVgDkyX1Nea9+kJKk93eCXFPzUYQB8Ln5vAAL9fboj2UaY
 Y2JnEscVZcXijobcVA9aIp0HY3TvjWE1Ny6SPFBz3NjboKjBtPj2mFFOhws2ewgWC4Lu
 YQwg==
X-Gm-Message-State: AOAM532pdmj+DTTJHbvjbMIbQnVVS1EUPVWQdxTH3AIcRny16/gcnhSJ
 o+bXyZDK0lM+R8O7ZNWqQgrIaCCUTdBSINDGN/+e7F3Qlreutg==
X-Google-Smtp-Source: ABdhPJxPZFizGCuEZxfK28UJZWcvRm+GmVHQWoGplShYjDG6INlUEiGCBigpJRN/JFN9m9/LnAAtY+hZrEOda5PvFe0=
X-Received: by 2002:a37:7e87:: with SMTP id z129mr2415874qkc.243.1617185674894; 
 Wed, 31 Mar 2021 03:14:34 -0700 (PDT)
MIME-Version: 1.0
From: David Fussner <dfussner@HIDDEN>
Date: Wed, 31 Mar 2021 11:12:29 +0100
Message-ID: <CADF+RthX8DJtG01uR-njt=MbXq46nh5BGqX=ShyUcScm6Yk2rA@HIDDEN>
Subject: 28.0.50; gcc 5.5.0 -Wstrict-overflow warning in INT_ADD_WRAPV
To: bug-gnu-emacs@HIDDEN
Content-Type: text/plain; charset="UTF-8"
Received-SPF: pass client-ip=2607:f8b0:4864:20::729;
 envelope-from=dfussner@HIDDEN; helo=mail-qk1-x729.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

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




Acknowledgement sent to David Fussner <dfussner@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#47518; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 21 Apr 2021 00:30:02 UTC

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