summaryrefslogtreecommitdiff
path: root/lib/intprops.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2020-09-17 12:17:15 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2020-09-17 12:17:37 -0700
commit494aaa530b32b4290df9a31d123bf1825eda7217 (patch)
tree0d5d83fa2f71a9032a2501ce0ba1c1597ac310d5 /lib/intprops.h
parent8125325281a491de9e0a6edc3c4d40d77c026114 (diff)
downloadgnulib-494aaa530b32b4290df9a31d123bf1825eda7217.tar.gz
intprops, xalloc: avoid __builtin_mul_overflow_p with Clang
Problem reported by Nelson H. F. Beebe for clang 9.0.1 in: https://lists.gnu.org/r/grep-devel/2020-09/msg00028.html * lib/intprops.h (_GL_HAS_BUILTIN_OVERFLOW_P) [__clang__]: Define to 0. * lib/xalloc-oversized.h (xalloc_oversized) [__clang__]: Do not use __builtin_mul_overflow_p.
Diffstat (limited to 'lib/intprops.h')
-rw-r--r--lib/intprops.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/intprops.h b/lib/intprops.h
index df66a3877a..cb086715bc 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -244,7 +244,13 @@
/* True if __builtin_add_overflow_p (A, B, C) works, and similarly for
__builtin_sub_overflow_p and __builtin_mul_overflow_p. */
-#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
+#ifdef __clang__
+/* Clang 9 lacks __builtin_mul_overflow_p, and even if it did it would
+ presumably run afoul of Clang bug 16404. */
+# define _GL_HAS_BUILTIN_OVERFLOW_P 0
+#else
+# define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
+#endif
/* The _GL*_OVERFLOW macros have the same restrictions as the
*_RANGE_OVERFLOW macros, except that they do not assume that operands