Richard W.M. Jones wrote:
Could this be a bug in GCC?  It's turning 2^63-1 into -1 without even
issuing a warning ...

Yes, it's a GCC bug. I filed a bug report here:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81650

I installed the attached patch into Gnulib to work around the bug.
From dbeec5dcb3dadd92773caae94fe57b921c4c86e8 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Tue, 1 Aug 2017 09:52:40 -0700
Subject: [PATCH] manywarnings: port to 32-bit GCC bug

Problem reported by Pino Toscano in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-07/msg00150.html
* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC): Use 2**31 - 1,
not 2**63 - 1, to work around the following GCC bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81650
---
 ChangeLog          | 9 +++++++++
 m4/manywarnings.m4 | 6 +++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7aedb71..44bdf79 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2017-08-01  Paul Eggert  <egg...@cs.ucla.edu>
+
+	manywarnings: port to 32-bit GCC bug
+	Problem reported by Pino Toscano in:
+	http://lists.gnu.org/archive/html/bug-gnulib/2017-07/msg00150.html
+	* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC): Use 2**31 - 1,
+	not 2**63 - 1, to work around the following GCC bug:
+	https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81650
+
 2017-07-30  Paul Eggert  <egg...@cs.ucla.edu>
 
 	backupfile: new function to validate backup suffix
diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4
index 2d35eff..6cf1be7 100644
--- a/m4/manywarnings.m4
+++ b/m4/manywarnings.m4
@@ -1,4 +1,4 @@
-# manywarnings.m4 serial 8
+# manywarnings.m4 serial 9
 dnl Copyright (C) 2008-2017 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -259,8 +259,8 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
   # gcc --help=warnings outputs an unusual form for these options; list
   # them here so that the above 'comm' command doesn't report a false match.
   # Would prefer "min (PTRDIFF_MAX, SIZE_MAX)", but it must be a literal:
-  ptrdiff_max_max=9223372036854775807
-  gl_manywarn_set="$gl_manywarn_set -Walloc-size-larger-than=$ptrdiff_max_max"
+  ptrdiff_max_min=2147483647
+  gl_manywarn_set="$gl_manywarn_set -Walloc-size-larger-than=$ptrdiff_max_min"
   gl_manywarn_set="$gl_manywarn_set -Warray-bounds=2"
   gl_manywarn_set="$gl_manywarn_set -Wformat-overflow=2"
   gl_manywarn_set="$gl_manywarn_set -Wformat-truncation=2"
-- 
2.7.4

Reply via email to