From: "Maciej W. Rozycki" <macro@wdc.com>
To: libc-alpha@sourceware.org
Subject: [PATCH v2] string: Fix GCC 11 `-Werror=stringop-overread' error
Date: Mon, 31 Aug 2020 14:26:47 +0100 (BST) [thread overview]
Message-ID: <alpine.LFD.2.21.2008311421160.20055@redsun52.ssa.fujisawa.hgst.com> (raw)
Fix a compilation error:
In function '__rawmemchr',
inlined from '__rawmemchr' at rawmemchr.c:27:1:
rawmemchr.c:36:12: error: 'memchr' specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overread]
36 | return memchr (s, c, (size_t)-1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
../o-iterator.mk:9: recipe for target '.../string/rawmemchr.o' failed
introduced with GCC 11 commit d14c547abd48 ("Add -Wstringop-overread
for reading past the end by string functions.").
---
Changes from v1:
- Wrap the pragma into `__GNUC_PREREQ (11, 0)'.
---
string/rawmemchr.c | 4 ++++
1 file changed, 4 insertions(+)
glibc-stringop-overread.diff
Index: glibc/string/rawmemchr.c
===================================================================
--- glibc.orig/string/rawmemchr.c
+++ glibc/string/rawmemchr.c
@@ -32,6 +32,10 @@ RAWMEMCHR (const void *s, int c)
PTRDIFF_MAX; the use of SIZE_MAX is deliberate here. */
DIAG_IGNORE_NEEDS_COMMENT (8, "-Wstringop-overflow=");
#endif
+#if __GNUC_PREREQ (11, 0)
+ /* Likewise GCC 11, with a different warning option. */
+ DIAG_IGNORE_NEEDS_COMMENT (11, "-Wstringop-overread");
+#endif
if (c != '\0')
return memchr (s, c, (size_t)-1);
DIAG_POP_NEEDS_COMMENT;
next reply other threads:[~2020-08-31 13:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-31 13:26 Maciej W. Rozycki [this message]
2020-09-01 18:13 ` Joseph Myers
2020-09-07 17:01 ` Joseph Myers
2020-09-16 21:39 ` Maciej W. Rozycki
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LFD.2.21.2008311421160.20055@redsun52.ssa.fujisawa.hgst.com \
--to=macro@wdc.com \
--cc=libc-alpha@sourceware.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).