From: Paul Eggert <eggert@cs.ucla.edu>
To: "Nelson H. F. Beebe" <beebe@math.utah.edu>
Cc: platform-testers@gnu.org, Gnulib bugs <bug-gnulib@gnu.org>,
grep-devel@gnu.org
Subject: Re: [platform-testers] new snapshot available: grep-3.4-almost.19-ff30
Date: Thu, 17 Sep 2020 12:22:09 -0700 [thread overview]
Message-ID: <a88796de-e281-d50d-d85e-fd40cc191b97@cs.ucla.edu> (raw)
In-Reply-To: <CMM.0.95.0.1600356616.beebe@gamma.math.utah.edu>
[-- Attachment #1: Type: text/plain, Size: 833 bytes --]
On 9/17/20 8:30 AM, Nelson H. F. Beebe wrote:
> On OpenMandriva Lx 4.1 (Mercury), with /usr/bin/cc == clang version 9.0.1,
> I get
>
> CC dfa.o
> In file included from dfa.c:61:
> ./xalloc.h:94:7: error: use of unknown builtin '__builtin_mul_overflow_p' [-Wimplicit-function-declaration]
> if (xalloc_oversized (n, s))
> ^
> ./xalloc-oversized.h:46:4: note: expanded from macro 'xalloc_oversized'
> __builtin_mul_overflow_p (n, s, (__xalloc_count_type) 1)
> ^
> ... long cascade of similar errors ...
Thanks for reporting that. I guess Clang 9.0.1 defines __GNUC__ to be >=7 even
though it doesn't implement all GCC 7 features. I installed the attached patch
into Gnulib to try to work around this glitch, and this patch should appear in
Grep the next time it syncs with Gnulib. cc'ing to bug-gnulib.
[-- Attachment #2: 0001-intprops-xalloc-avoid-__builtin_mul_overflow_p-with-.patch --]
[-- Type: text/x-patch, Size: 2642 bytes --]
From 494aaa530b32b4290df9a31d123bf1825eda7217 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 17 Sep 2020 12:17:15 -0700
Subject: [PATCH] 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.
---
ChangeLog | 8 ++++++++
lib/intprops.h | 8 +++++++-
lib/xalloc-oversized.h | 2 +-
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b484c8dec..a3a8ab1e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
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:
diff --git a/lib/intprops.h b/lib/intprops.h
index df66a3877..cb086715b 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
diff --git a/lib/xalloc-oversized.h b/lib/xalloc-oversized.h
index 13ee23031..7cd4a74f0 100644
--- a/lib/xalloc-oversized.h
+++ b/lib/xalloc-oversized.h
@@ -41,7 +41,7 @@ typedef size_t __xalloc_count_type;
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__
--
2.17.1
next parent reply other threads:[~2020-09-17 19:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CMM.0.95.0.1600356616.beebe@gamma.math.utah.edu>
2020-09-17 19:22 ` Paul Eggert [this message]
2020-09-17 21:31 ` [platform-testers] new snapshot available: grep-3.4-almost.19-ff30 Paul Eggert
[not found] <m2imce1gpu.fsf@meyering.net>
[not found] ` <CAH8yC8n4tmO6__C=zP0JZRmc5_ddg7L6uGAuLfjV_Bm+i3oYsA@mail.gmail.com>
2020-09-17 18:23 ` Paul Eggert
2020-09-17 21:07 ` Jeffrey Walton
2020-09-18 17:36 ` Paul Eggert
[not found] ` <CAH8yC8mn1YMN+fgzJBKEk9+y0qTqfO2zHbWUyO2ekVq-PimX3Q@mail.gmail.com>
2020-09-17 14:40 ` Jim Meyering
2020-09-17 22:46 ` Bruno Haible
2020-09-19 13:12 ` Bruno Haible
2020-09-19 14:21 ` Jeffrey Walton
2020-09-19 19:15 ` Bruno Haible
2020-09-20 19:28 ` Bruno Haible
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a88796de-e281-d50d-d85e-fd40cc191b97@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=beebe@math.utah.edu \
--cc=bug-gnulib@gnu.org \
--cc=grep-devel@gnu.org \
--cc=platform-testers@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).