Thanks for those fixes from the bleeding edge! One minor point: a strict reading
of the GCC 7 manual would say that calls to __builtin_add_overflow_p etc. should
use __typeof__ to avoid overflow in the very expression one is trying to check
for overflow, so I installed the attached followup.
From 14adf7b4d204636affa553049da0c521f53fc57d Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Mon, 29 Aug 2016 10:08:32 -0700
Subject: [PATCH] intprops.h: use __typeof__ with GCC 7
* lib/intprops.h (_GL_ADD_OVERFLOW, _GL_SUBTRACT_OVERFLOW)
(_GL_MULTIPLY_OVERFLOW): Use __typeof__ as in the GCC manual.
This avoids computing the expression's value (which might overflow!).
---
ChangeLog | 7 +++++++
lib/intprops.h | 6 +++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8e7ab74..70012b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2016-08-29 Paul Eggert <egg...@cs.ucla.edu>
+
+ intprops.h: use __typeof__ with GCC 7
+ * lib/intprops.h (_GL_ADD_OVERFLOW, _GL_SUBTRACT_OVERFLOW)
+ (_GL_MULTIPLY_OVERFLOW): Use __typeof__ as in the GCC manual.
+ This avoids computing the expression's value (which might overflow!).
+
2016-08-29 Jim Meyering <meyer...@fb.com>
intprops.h, xalloc-oversized.h: work with gcc 7
diff --git a/lib/intprops.h b/lib/intprops.h
index d2a65cc..32ee71a 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -240,11 +240,11 @@ verify (TYPE_MAXIMUM (long long int) == LLONG_MAX);
that the result (e.g., A + B) has that type. */
#if _GL_HAS_BUILTIN_OVERFLOW_P
# define _GL_ADD_OVERFLOW(a, b, min, max) \
- __builtin_add_overflow_p (a, b, (a) + (b))
+ __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
- __builtin_sub_overflow_p (a, b, (a) - (b))
+ __builtin_sub_overflow_p (a, b, (__typeof__ ((a) - (b))) 0)
# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
- __builtin_mul_overflow_p (a, b, (a) * (b))
+ __builtin_mul_overflow_p (a, b, (__typeof__ ((a) * (b))) 0)
#elif _GL_HAS_BUILTIN_OVERFLOW_WITH_NULL
# define _GL_ADD_OVERFLOW(a, b, min, max) \
__builtin_add_overflow (a, b, (__typeof__ ((a) + (b)) *) 0)
--
2.7.4