diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2016-08-29 10:08:32 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2016-08-29 10:09:50 -0700 |
commit | d22721e2efd88f26588c9710000eb1eeb3ec40de (patch) | |
tree | 5f2f9b2cb9449087b46e0bf43854df37729242af /lib/intprops.h | |
parent | 175b4e22f99e00996b72f822f5ae54dca8243d19 (diff) | |
download | gnulib-d22721e2efd88f26588c9710000eb1eeb3ec40de.tar.gz |
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!).
Diffstat (limited to 'lib/intprops.h')
-rw-r--r-- | lib/intprops.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/intprops.h b/lib/intprops.h index d2a65cc5e4..32ee71a0fd 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) |