+2020-12-18 Paul Eggert <eggert@cs.ucla.edu>
+
+ intprops: port to ICC 2021.1 Beta 20201112
+ * lib/intprops.h (_GL_HAS_BUILTIN_OVERFLOW_P):
+ Port to ICC 2021.1, which has a non-working __builtin_mul_overflow_p.
+ Add a clause for other compilers that claim to support
+ __builtin_mul_overflow_p, since we might as well find out about
+ slackers other than Clang and ICC.
+ (INT_MULTIPLY_WRAPV): ICC 2021 has GCC bug 91450, so treat it
+ like older GCCs even when it claims to be a newer one.
+
2020-12-18 Bruno Haible <bruno@clisp.org>
intprops: Avoid potentially buggy __builtin_add_overflow in GCC 5, 6.
/* True if __builtin_add_overflow_p (A, B, C) works, and similarly for
__builtin_sub_overflow_p and __builtin_mul_overflow_p. */
-#ifdef __clang__
-/* Clang 9 lacks __builtin_mul_overflow_p, and even if it did it would
- presumably run afoul of Clang bug 16404. */
+#if defined __clang__ || defined __ICC
+/* Clang 11 lacks __builtin_mul_overflow_p, and even if it did it
+ would presumably run afoul of Clang bug 16404. ICC 2021.1's
+ __builtin_add_overflow_p etc. are not treated as integral constant
+ expressions even when all arguments are. */
# define _GL_HAS_BUILTIN_OVERFLOW_P 0
+#elif defined __has_builtin
+# define _GL_HAS_BUILTIN_OVERFLOW_P __has_builtin (__builtin_mul_overflow_p)
#else
# define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
#endif
_GL_INT_OP_WRAPV (a, b, r, -, _GL_INT_SUBTRACT_RANGE_OVERFLOW)
#endif
#if _GL_HAS_BUILTIN_MUL_OVERFLOW
-# if (9 < __GNUC__ + (3 <= __GNUC_MINOR__) \
- || (__GNUC__ == 8 && 4 <= __GNUC_MINOR__))
+# if ((9 < __GNUC__ + (3 <= __GNUC_MINOR__) \
+ || (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) \
+ && !defined __ICC)
# define INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r)
# else
/* Work around GCC bug 91450. */