From: Paul Eggert Date: Fri, 18 Dec 2020 18:18:40 +0000 (-0800) Subject: intprops: port to ICC 2021.1 Beta 20201112 X-Git-Tag: v1.0~3353 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=2d83594993812e9b404a66936fc0aaf115eef273;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index ae62fd7792..c723356c11 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2020-12-18 Paul Eggert + + 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 intprops: Avoid potentially buggy __builtin_add_overflow in GCC 5, 6. diff --git a/lib/intprops.h b/lib/intprops.h index 2472962e67..52e60e5e2d 100644 --- a/lib/intprops.h +++ b/lib/intprops.h @@ -246,10 +246,14 @@ /* 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 @@ -385,8 +389,9 @@ _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. */