Message ID | alpine.LFD.2.21.2008302126320.24175@redsun52.ssa.fujisawa.hgst.com |
---|---|
State | Superseded |
Headers |
Return-Path: <libc-alpha-bounces@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4C0E73851C22; Sun, 30 Aug 2020 20:41:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C0E73851C22 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1598820103; bh=RNhgfIVOhynTgYS6IZ7a+NRlAJNanCCRrpXQdlvcoJM=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=D1IbOpVPwanpFlsiswBaD3eEtoOrT4fj+T+lVLNaJKIL5SxIPnd9GLlBRcwdc+9YG eS7rCFmABgSgzyaxQgmNlhi5UaO4UX0G8qMdy/5AEouYKXxPclUR7wIyQ6LQ1jB/KQ smqnoz5mRQOuUNxmTNZsDsSh+Uw355JB0Kj+dzuU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by sourceware.org (Postfix) with ESMTPS id F023E3857831 for <libc-alpha@sourceware.org>; Sun, 30 Aug 2020 20:41:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org F023E3857831 IronPort-SDR: Ee5LHhYh3TopFWTB1zthMuDkZRQGRF1xH6zQYix9a5y73UdTCaZwVjYZNimmQmKPQyGzKNbO8V nLpFX9B7cE5UFVsqd21CKozSU4izdrRG6ViYQmNAsEAxeK5BtGg6pA1SbcHltrN/LUJ75LiPRC WjJ2oQdXu1UlEt1Hw9TBYusv/hj6mb0c6lM2BFrmH3FCj8ntjoC0gdj3rN58L9iVBzlxWivrl8 29gnuRPOWiYuV2b4abg+kZeUNpD8NpztWUYaKsdrQZ0reE0+QeZx1qO2gCtL+/Nxr3MTlRJuPE QfI= X-IronPort-AV: E=Sophos;i="5.76,373,1592841600"; d="scan'208";a="146173139" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 31 Aug 2020 04:41:39 +0800 IronPort-SDR: YV9U4Ffen09v1D0lZSpl8tPgR97lXbKFkWKcuOMFz+nGFcEQCUR2WF1Eu3UmsrsBefGUXGMWne fKVpTrNCdkBw== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2020 13:29:08 -0700 IronPort-SDR: MUCfomYRXI7LGBsER4/JmntNErJKw6Hxi0XoZbgFkQIHitU3gxNcjN/lLw5fnR3AvFlbVdBSYM KdEZYh+U94QQ== WDCIronportException: Internal Received: from unknown (HELO redsun52) ([10.149.66.28]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2020 13:41:39 -0700 Date: Sun, 30 Aug 2020 21:41:31 +0100 (BST) To: libc-alpha@sourceware.org Subject: [PATCH] string: Fix GCC 11 `-Werror=stringop-overread' error Message-ID: <alpine.LFD.2.21.2008302126320.24175@redsun52.ssa.fujisawa.hgst.com> User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_ASCII_DIVIDERS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> From: "Maciej W. Rozycki via Libc-alpha" <libc-alpha@sourceware.org> Reply-To: "Maciej W. Rozycki" <macro@wdc.com> Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces@sourceware.org> |
Series |
string: Fix GCC 11 `-Werror=stringop-overread' error
|
|
Commit Message
Maciej W. Rozycki
Aug. 30, 2020, 8:41 p.m. UTC
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."). --- string/rawmemchr.c | 2 ++ 1 file changed, 2 insertions(+) glibc-stringop-overread.diff
Comments
* Maciej W. Rozycki via Libc-alpha: > glibc-stringop-overread.diff > Index: glibc/string/rawmemchr.c > =================================================================== > --- glibc.orig/string/rawmemchr.c > +++ glibc/string/rawmemchr.c > @@ -31,6 +31,8 @@ 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="); > + /* Likewise GCC 11, with a different warning option. */ > + DIAG_IGNORE_NEEDS_COMMENT (11, "-Wstringop-overread"); > #endif I think this needs to be in its own __GNUC_PREREQ block because GCC 7 does not have -Wstringop-overread. Thanks, Florian
On Mon, 31 Aug 2020, Florian Weimer wrote: > > Index: glibc/string/rawmemchr.c > > =================================================================== > > --- glibc.orig/string/rawmemchr.c > > +++ glibc/string/rawmemchr.c > > @@ -31,6 +31,8 @@ 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="); > > + /* Likewise GCC 11, with a different warning option. */ > > + DIAG_IGNORE_NEEDS_COMMENT (11, "-Wstringop-overread"); > > #endif > > I think this needs to be in its own __GNUC_PREREQ block because GCC 7 > does not have -Wstringop-overread. Umm, I never used this feature before and got confused with the version mismatch (7 vs 8) right above: #if __GNUC_PREREQ (7, 0) DIAG_IGNORE_NEEDS_COMMENT (8, "-Wstringop-overflow="); #endif misleading me into thinking GCC 7 is the version that introduced the `_Pragma' feature we use here. Joseph: has the mismatch been intentional? I have posted v2 now. Maciej
On Mon, 31 Aug 2020, Maciej W. Rozycki via Libc-alpha wrote: > Umm, I never used this feature before and got confused with the version > mismatch (7 vs 8) right above: > > #if __GNUC_PREREQ (7, 0) > DIAG_IGNORE_NEEDS_COMMENT (8, "-Wstringop-overflow="); > #endif > > misleading me into thinking GCC 7 is the version that introduced the > `_Pragma' feature we use here. > > Joseph: has the mismatch been intentional? All GCC versions supported for building glibc support the relevant pragma. However, the pragma gives an error if the -W option named isn't supported in the GCC version being used, so __GNUC_PREREQ conditionals are needed around uses of the pragma with options not present in the minimum GCC version for building glibc (currently GCC 6). The version number in the macro call is ignored by the macro and is only for human readers. It indicates the *most recent* GCC version with which the warning has been observed, and is intended as a hint that a particular use of the pragma might be obsolete, if the version named is older than the oldest GCC version still supported for building glibc - but actually determining whether it is obsolete would require removing the pragma and trying building with that GCC version. That number is more relevant where the pragma is working around a GCC bug, and thus might well not be needed with newer GCC, than where the code (typically a testcase) is deliberately doing something that is deliberately warned about (which is common for tests of various corner cases) and thus the warning is not expected to disappear with newer GCC.
Index: glibc/string/rawmemchr.c =================================================================== --- glibc.orig/string/rawmemchr.c +++ glibc/string/rawmemchr.c @@ -31,6 +31,8 @@ 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="); + /* 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);