From patchwork Fri Feb 19 14:38:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 42117 Return-Path: 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 33299398B8B1; Fri, 19 Feb 2021 14:38:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 33299398B8B1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1613745505; bh=98iGO0kbbmH7sFPvb9om4aWMGdlFSZilDQa0aHfNNVk=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=T7bOSO4asiyxj484K0P/MYhj9vqsj88dIOq/U09ZXzwlAFhazTLYQdXDVN45w1MTk cN6t1uMGEolyX+sirInk88oqxJS3J9mbKS0fErQU1fNcBSxsbmcfLyumNtiO9tlV+x E1xgIuv484TqWMLeMU/w8OLCd/Nfxb8u/h9Dvgwc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 77CCF398B8A0 for ; Fri, 19 Feb 2021 14:38:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 77CCF398B8A0 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-440-nyPZuOAvNDeaN75Gc78aVA-1; Fri, 19 Feb 2021 09:38:19 -0500 X-MC-Unique: nyPZuOAvNDeaN75Gc78aVA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 606CEC73A0 for ; Fri, 19 Feb 2021 14:38:18 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-113-131.ams2.redhat.com [10.36.113.131]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8180319708; Fri, 19 Feb 2021 14:38:17 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH] string: Work around GCC PR 98512 in rawmemchr Date: Fri, 19 Feb 2021 15:38:53 +0100 Message-ID: <87a6s0azr6.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Cc: Martin Sebor Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The GCC fix is not likely to land in GCC 11. Thanks, Florian --- string/rawmemchr.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/string/rawmemchr.c b/string/rawmemchr.c index 59bbeeaa42..b8523118e5 100644 --- a/string/rawmemchr.c +++ b/string/rawmemchr.c @@ -22,24 +22,28 @@ # define RAWMEMCHR __rawmemchr #endif +/* The pragmata should be nested inside RAWMEMCHR below, but that + triggers GCC PR 98512. */ +DIAG_PUSH_NEEDS_COMMENT; +#if __GNUC_PREREQ (7, 0) +/* 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 + /* Find the first occurrence of C in S. */ void * RAWMEMCHR (const void *s, int c) { - DIAG_PUSH_NEEDS_COMMENT; -#if __GNUC_PREREQ (7, 0) - /* 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); - DIAG_POP_NEEDS_COMMENT; return (char *)s + strlen (s); } libc_hidden_def (__rawmemchr) weak_alias (__rawmemchr, rawmemchr) + +DIAG_POP_NEEDS_COMMENT;