From patchwork Wed Jun 19 13:08:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1949686 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=f85f+K1I; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W43rn1V0Nz20KL for ; Wed, 19 Jun 2024 23:10:33 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 786153885C30 for ; Wed, 19 Jun 2024 13:10:31 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 993333885C28 for ; Wed, 19 Jun 2024 13:10:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 993333885C28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 993333885C28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718802605; cv=none; b=ovSmyTLU6/qrBZBDlz9t9eGXtEGBCV8RKv+Bcfhs5wEPwJ+HpjF/FaSyMSQeFsjF1zCaptoB2rI3gW6BeMbaOnfhMoTLZ/Q8I1dHXnxolEAZqdB7+70A//ZsvPRDwocap71J15eqE8Nafdak4Ssyeu2U00VVPJVPHzG641kUsr0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718802605; c=relaxed/simple; bh=08ps7pF3gDRbG7Y2vyHBN7FgDYrape1fFKIWwWuS41U=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=FPG9XfC981i9AfZBDfRUsWaUBSt3Omx0awiXd3Q+p/2X8tWeIQO04/aGMVp0IZcCiP4Ik5Nx81zRMYAt/gWeJ6YkI1SfGiWbYSOo18tJZ0ZObMYsSG5xJZmFnwPKQovmnPHFUfBP4d5ME4ftcgZsbtFWgR8Pmf1A2eJdC4nSRJE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718802603; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tTtPsdNZaY/SiCWUqqezvKIvhPT3QYU1+oEA9OG4K8M=; b=f85f+K1I/NQdk8K3tBgVfxdwurvyXXZC3hl2ygpF/l6tKbDueKTdo4mDtHvw5S1Fl8UpOz nLp8rBuSXv6XW6I2dR7lg8dIUGLFszXOcx/Wc+oJQBD/l2Hm0cbOzrdJf99YWeByZr/2Ae FxvBDiJaO0E0JT+v7ajncAMDQ6uJjlE= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-687-5gSoHhYEOoKq2pv4TrsE-Q-1; Wed, 19 Jun 2024 09:09:59 -0400 X-MC-Unique: 5gSoHhYEOoKq2pv4TrsE-Q-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A1F0F19560A2; Wed, 19 Jun 2024 13:09:57 +0000 (UTC) Received: from localhost (unknown [10.42.28.182]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AE48319560AF; Wed, 19 Jun 2024 13:09:56 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Cc: Stephan Bergmann Subject: [committed] libstdc++: Fix warning regressions in Date: Wed, 19 Jun 2024 14:08:21 +0100 Message-ID: <20240619130954.1695641-1-jwakely@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.8 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_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Tested x86_64-linux. Pushed to trunk. -- >8 -- I caused some new warnings with -Wsystem-headers with my recent changes to std::get_temporary_buffer and std::_Temporary_buffer. There's a -Wsign-compare warning which can be avoided by casting the ptrdiff_t argument to size_t (which also conveniently rejects negative values). There's also a -Wdeprecated-declarations warning because I moved where std::get_temporary_buffer is called, but didn't move the diagnostic pragmas that suppress the warning for calling it. libstdc++-v3/ChangeLog: * include/bits/stl_tempbuf.h (__get_temporary_buffer): Cast argument to size_t to handle negative values and suppress -Wsign-compare warning. (_Temporary_buffer): Move diagnostic pragmas to new location of call to std::get_temporary_buffer. --- libstdc++-v3/include/bits/stl_tempbuf.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/include/bits/stl_tempbuf.h b/libstdc++-v3/include/bits/stl_tempbuf.h index fa03fd27704..759c4937744 100644 --- a/libstdc++-v3/include/bits/stl_tempbuf.h +++ b/libstdc++-v3/include/bits/stl_tempbuf.h @@ -82,7 +82,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline _Tp* __get_temporary_buffer(ptrdiff_t __len) _GLIBCXX_NOTHROW { - if (__builtin_expect(__len > (size_t(-1) / sizeof(_Tp)), 0)) + if (__builtin_expect(size_t(__len) > (size_t(-1) / sizeof(_Tp)), 0)) return 0; #if __cpp_aligned_new @@ -200,6 +200,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION size_type _M_original_len; struct _Impl { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" explicit _Impl(ptrdiff_t __original_len) { @@ -208,6 +210,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_len = __p.second; _M_buffer = __p.first; } +#pragma GCC diagnostic pop ~_Impl() { std::__detail::__return_temporary_buffer(_M_buffer, _M_len); } @@ -315,8 +318,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __ucr(__first, __last, __seed); } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" template _Temporary_buffer<_ForwardIterator, _Tp>:: _Temporary_buffer(_ForwardIterator __seed, size_type __original_len) @@ -324,7 +325,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { std::__uninitialized_construct_buf(begin(), end(), __seed); } -#pragma GCC diagnostic pop _GLIBCXX_END_NAMESPACE_VERSION } // namespace