Mercurial > gnulib
changeset 18388:24d7281d8acb
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!).
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Mon, 29 Aug 2016 10:08:32 -0700 |
parents | 6821cce38136 |
children | a05c0ede6620 |
files | ChangeLog lib/intprops.h |
diffstat | 2 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Mon Aug 29 09:45:18 2016 -0700 +++ b/ChangeLog Mon Aug 29 10:08:32 2016 -0700 @@ -1,3 +1,10 @@ +2016-08-29 Paul Eggert <eggert@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 <meyering@fb.com> intprops.h, xalloc-oversized.h: work with gcc 7
--- a/lib/intprops.h Mon Aug 29 09:45:18 2016 -0700 +++ b/lib/intprops.h Mon Aug 29 10:08:32 2016 -0700 @@ -240,11 +240,11 @@ 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)