summaryrefslogtreecommitdiff
path: root/lib/xalloc-oversized.h
diff options
context:
space:
mode:
authorJim Meyering <meyering@fb.com>2016-08-29 16:33:43 -0700
committerJim Meyering <meyering@fb.com>2016-08-29 16:34:21 -0700
commita56908381dd1ed630007a04ad03db17b1795e539 (patch)
tree62756d4fd15b5b4c0e1ee29ef7a2a1e074d38c40 /lib/xalloc-oversized.h
parentabae112b34572cd3869ce4fc81dddb5c2a7394c4 (diff)
downloadgnulib-a56908381dd1ed630007a04ad03db17b1795e539.tar.gz
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.
Diffstat (limited to 'lib/xalloc-oversized.h')
-rw-r--r--lib/xalloc-oversized.h13
1 files changed, 1 insertions, 12 deletions
diff --git a/lib/xalloc-oversized.h b/lib/xalloc-oversized.h
index 9954f50336..53e6556c61 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))) \