From 96b8849e0203df4bd08610b6d58b3cfa7a2c72b5 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 14 Aug 2019 18:05:57 -0700 Subject: [PATCH] intprops: pacify picky GCC MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * 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 7fe978f4a8..4b752fb06c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2019-08-14 Paul Eggert + 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 556cadec80..54012874df 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.39.5