bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH] intprops: pacify picky GCC


From: Paul Eggert
Subject: [PATCH] intprops: pacify picky GCC
Date: Wed, 14 Aug 2019 18:06:32 -0700

* lib/intprops.h (_GL_BUILTIN_MUL_OVERFLOW):
Pacify GCC’s complaints about ignoring __builtin_mul_overflow’s
possibly-incorrect result.
(_GL_INT_MULTIPLY_RANGE_OVERFLOW): Pacify GCC’s complaints
about (A) used as a boolean, when A is an expression like 3 * 4.
---
 ChangeLog      | 7 +++++++
 lib/intprops.h | 6 ++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7fe978f4a..4b752fb06 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2019-08-14  Paul Eggert  <address@hidden>
 
+       intprops: pacify picky GCC
+       * lib/intprops.h (_GL_BUILTIN_MUL_OVERFLOW):
+       Pacify GCC’s complaints about ignoring __builtin_mul_overflow’s
+       possibly-incorrect result.
+       (_GL_INT_MULTIPLY_RANGE_OVERFLOW): Pacify GCC’s complaints
+       about (A) used as a boolean, when A is an expression like 3 * 4.
+
        intprops: support unsigned *_WRAPV results
        Add support for unsigned, unsigned long, and unsigned long long
        results to INT_ADD_WRAPV, INT_SUBTRACT_WRAPV, and
diff --git a/lib/intprops.h b/lib/intprops.h
index 556cadec8..54012874d 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -366,7 +366,7 @@
 #define _GL_BUILTIN_MUL_OVERFLOW(a, b, r) \
   ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && EXPR_SIGNED (a) && EXPR_SIGNED (b) \
     && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \
-   ? (__builtin_mul_overflow (a, b, r), 1) \
+   ? ((void) __builtin_mul_overflow (a, b, r), 1) \
    : __builtin_mul_overflow (a, b, r))
 
 /* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390.  See:
@@ -540,7 +540,9 @@
              : (tmax) / -(b)) \
             <= -1 - (a))) \
       : INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (b, tmin)) && (b) == -1 \
-      ? (EXPR_SIGNED (a) ? 0 < (a) + (tmin) : (a) && -1 - (tmin) < (a) - 1) \
+      ? (EXPR_SIGNED (a) \
+        ? 0 < (a) + (tmin) \
+        : 0 < (a) && -1 - (tmin) < (a) - 1) \
       : (tmin) / (b) < (a)) \
    : (b) == 0 \
    ? 0 \
-- 
2.21.0




reply via email to

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