2020-09-17 Paul Eggert <eggert@cs.ucla.edu>
+ 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.
+
libc-config: port __THROW to Ubuntu 4
* lib/cdefs.h (__THROW): Do not use __attribute__ ((__nothrow__))
for GCC 3.3. Problem reported by Jeffrey Walton in:
/* 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
positive and N must be nonnegative. This is a macro, not a
function, so that it works correctly even when SIZE_MAX < N. */
-#if 7 <= __GNUC__
+#if 7 <= __GNUC__ && !defined __clang__
# define xalloc_oversized(n, s) \
__builtin_mul_overflow_p (n, s, (__xalloc_count_type) 1)
#elif 5 <= __GNUC__ && !defined __ICC && !__STRICT_ANSI__