+2020-12-18 Bruno Haible <bruno@clisp.org>
+
+ intprops: Avoid potentially buggy __builtin_add_overflow in GCC 5, 6.
+ Reported by Stefan Liebler <stli@linux.ibm.com> in
+ <https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00152.html>.
+ * lib/intprops.h (_GL_HAS_BUILTIN_ADD_OVERFLOW): Don't define for
+ GCC 5.x and 6.x.
+ * lib/glob.c (size_add_wrapv): Don't use __builtin_add_overflow for
+ GCC 5.x and 6.x.
+
2020-12-17 Bruno Haible <bruno@clisp.org>
free: Fix warning.
static bool
size_add_wrapv (size_t a, size_t b, size_t *r)
{
-#if 5 <= __GNUC__ && !defined __ICC
+#if 7 <= __GNUC__ && !defined __ICC
return __builtin_add_overflow (a, b, r);
#else
*r = a + b;
/* True if __builtin_add_overflow (A, B, P) and __builtin_sub_overflow
(A, B, P) work when P is non-null. */
-#if 5 <= __GNUC__ && !defined __ICC
+/* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x,
+ see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269>. */
+#if 7 <= __GNUC__ && !defined __ICC
# define _GL_HAS_BUILTIN_ADD_OVERFLOW 1
#elif defined __has_builtin
# define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow)