From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1105) id 9410C3894C17; Mon, 7 Sep 2020 17:01:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9410C3894C17 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Joseph Myers To: glibc-cvs@sourceware.org Subject: [glibc] string: Fix GCC 11 `-Werror=stringop-overread' error X-Act-Checkin: glibc X-Git-Author: Maciej W. Rozycki X-Git-Refname: refs/heads/master X-Git-Oldrev: 7b51d9f69e742d29b335f4ced07ed0f191b12f82 X-Git-Newrev: 3357087b2a95a33dbb38579c9bf7b23f1f85c7a1 Message-Id: <20200907170144.9410C3894C17@sourceware.org> Date: Mon, 7 Sep 2020 17:01:44 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2020 17:01:44 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=3357087b2a95a33dbb38579c9bf7b23f1f85c7a1 commit 3357087b2a95a33dbb38579c9bf7b23f1f85c7a1 Author: Maciej W. Rozycki 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);