bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH] manywarnings: port to 64-bit GCC builds of Emacs


From: Paul Eggert
Subject: [PATCH] manywarnings: port to 64-bit GCC builds of Emacs
Date: Fri, 4 Aug 2017 15:15:59 -0700

* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC): Compute max safe
object size rather than hardwiring 2147483647.  This is needed to
build GNU Emacs, which has one conditional (and used
only-in-theory) call to malloc with a literal greater than
2147483647.
---
 ChangeLog          |  9 +++++++++
 m4/manywarnings.m4 | 19 +++++++++++++++----
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8d2b695b7..caab63ee0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2017-08-04  Paul Eggert  <address@hidden>
+
+       manywarnings: port to 64-bit GCC builds of Emacs
+       * m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC): Compute max safe
+       object size rather than hardwiring 2147483647.  This is needed to
+       build GNU Emacs, which has one conditional (and used
+       only-in-theory) call to malloc with a literal greater than
+       2147483647.
+
 2017-08-04  Bruno Haible  <address@hidden>
 
        Relax the license of some modules with no runtime code.
diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4
index 6cf1be7d3..6a8939b2c 100644
--- a/m4/manywarnings.m4
+++ b/m4/manywarnings.m4
@@ -1,4 +1,4 @@
-# manywarnings.m4 serial 9
+# manywarnings.m4 serial 10
 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,
@@ -258,9 +258,20 @@ 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_min=2147483647
-  gl_manywarn_set="$gl_manywarn_set -Walloc-size-larger-than=$ptrdiff_max_min"
+  # Would prefer "min (PTRDIFF_MAX, SIZE_MAX)", but it must be a literal
+  # and AC_COMPUTE_INT requires it to fit in a long:
+  AC_MSG_CHECKING([max safe object size])
+  AC_COMPUTE_INT([gl_alloc_max],
+    [(LONG_MAX < PTRDIFF_MAX ? LONG_MAX : PTRDIFF_MAX) < (size_t) -1
+     ? (LONG_MAX < PTRDIFF_MAX ? LONG_MAX : PTRDIFF_MAX)
+     : (size_t) -1],
+    [[#include <limits.h>
+      #include <stddef.h>
+      #include <stdint.h>
+    ]],
+    [gl_alloc_max=2147483647])
+  AC_MSG_RESULT([$gl_alloc_max])
+  gl_manywarn_set="$gl_manywarn_set -Walloc-size-larger-than=$gl_alloc_max"
   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.13.3




reply via email to

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