public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Joseph Myers <jsm28@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc] string: Fix GCC 11 `-Werror=stringop-overread' error
Date: Mon,  7 Sep 2020 17:01:44 +0000 (GMT)	[thread overview]
Message-ID: <20200907170144.9410C3894C17@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=3357087b2a95a33dbb38579c9bf7b23f1f85c7a1

commit 3357087b2a95a33dbb38579c9bf7b23f1f85c7a1
Author: Maciej W. Rozycki <macro@wdc.com>
Date:   Mon Aug 31 14:26:47 2020 +0100

    string: Fix GCC 11 `-Werror=stringop-overread' error
    
    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.").

Diff:
---
 string/rawmemchr.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/string/rawmemchr.c b/string/rawmemchr.c
index b62d285d7e..d6ce8209be 100644
--- a/string/rawmemchr.c
+++ b/string/rawmemchr.c
@@ -31,6 +31,10 @@ RAWMEMCHR (const void *s, int c)
   /* GCC 8 warns about the size passed to memchr being larger than
      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);


                 reply	other threads:[~2020-09-07 17:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20200907170144.9410C3894C17@sourceware.org \
    --to=jsm28@sourceware.org \
    --cc=glibc-cvs@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).