From bb26f2c4cd826e8b20863354a3a79af95785f3b0 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 29 Aug 2016 16:33:43 -0700 Subject: [PATCH] xalloc-oversized.h: port __builtin_mul_overflow change to GCC 6.2.0 * lib/xalloc-oversized.h: Port this change to GCC 6.2.0, too, similarly to how it was done to intprops.h. --- ChangeLog | 6 ++++++ lib/xalloc-oversized.h | 13 +------------ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index cc437f5..d694076 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2016-08-29 Jim Meyering + + xalloc-oversized.h: port __builtin_mul_overflow change to GCC 6.2.0 + * lib/xalloc-oversized.h: Port this change to GCC 6.2.0, too, + similarly to how it was done to intprops.h. + 2016-08-29 Paul Eggert intprops.h: port recent changes to GCC 6.2.0 diff --git a/lib/xalloc-oversized.h b/lib/xalloc-oversized.h index 9954f50..53e6556 100644 --- a/lib/xalloc-oversized.h +++ b/lib/xalloc-oversized.h @@ -43,19 +43,8 @@ nonnegative. This is a macro, not a function, so that it works correctly even when SIZE_MAX < N. */ -#if 7 <= __GNUC__ +#if 7 <= __GNUC__ || __has_builtin (__builtin_add_overflow_p) # define xalloc_oversized(n, s) __builtin_mul_overflow_p (n, s, (size_t) 1) - -/* GCC 6 __builtin_mul_overflow should easily compute this. See: - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68120 */ -#elif 6 == __GNUC__ -# define xalloc_oversized(n, s) __builtin_mul_overflow (n, s, (size_t *) NULL) - -/* GCC 5 and Clang __builtin_mul_overflow needs a temporary, and - should be used only for non-constant operands, so that - xalloc_oversized is a constant expression if both arguments are. - Do not use this if pedantic, since pedantic GCC issues a diagnostic - for ({ ... }). */ #elif ((5 <= __GNUC__ \ || (__has_builtin (__builtin_mul_overflow) \ && __has_builtin (__builtin_constant_p))) \ -- 2.8.0.rc2