From patchwork Fri Sep 27 20:41:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1990409 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=LAlsERXm; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; 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 [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4XFj8C5FCnz1xtM for ; Sat, 28 Sep 2024 06:42:35 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 84700385DDD2 for ; Fri, 27 Sep 2024 20:42:33 +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.133.124]) by sourceware.org (Postfix) with ESMTP id E1FDA385DDC4 for ; Fri, 27 Sep 2024 20:42:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E1FDA385DDC4 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 E1FDA385DDC4 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727469733; cv=none; b=xMst/59wsVI+loB/BdbjgMqlR0Ulim7Q+A6e4sAytek8lX8bB1xe4WBowlgQPEAzkwXFCAGcsi+FsADLvYQJ3H8aYGwIvbUMag+0571JpPp9HMUxLiWIUQLbn0ORu7lJYlOAKvojpX18hoi0CTIxzoYbsXGp6M0I/2mqOoMk8gY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727469733; c=relaxed/simple; bh=ZiYTFZ9MA9pOwaJne+0hCRqp/pV5ePsslDWx8yGKHMk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=EIcGJFW/yO6HnZ+ml7u4sLEBYOd3gwYGmflxUOFLE5Pi4SVoXJRGuhbYoNiw52WJlhgR3TWOqtZ6Spu18sghrQWGVhk2Vj6eFZaCZYX5UmC2rYOqC9m1jg9BPSCDxtgH6el71iAsmnFYtUc8lruPnXdrZocyMr6uwmJdmO5YdmQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727469731; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5Hhiy3wOV+j2aUASF0UZO20lVX8d0qxJj+iQy67zmt0=; b=LAlsERXmXaq8oLaLNSRqhZge4p05xVtWGAb1GLz8SBMuw7nRLqqaoByQtbR+tkJjFX97+Z tGVi+6MCeQlcs7tmxaqmOEeCunRdpZOwmi9nZ6tWrhI180vpyAdS9A7WJ1LeojKtP8qvAL n5z9lR/cojgVS/tdLLXhBE5JU34naM4= Received: from mx-prod-mc-03.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-680-LPs4o1eEMRyYTCXciQcdGw-1; Fri, 27 Sep 2024 16:42:10 -0400 X-MC-Unique: LPs4o1eEMRyYTCXciQcdGw-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (unknown [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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 59FC018DB401; Fri, 27 Sep 2024 20:42:09 +0000 (UTC) Received: from localhost (unknown [10.42.28.136]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C6539195605A; Fri, 27 Sep 2024 20:42:08 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Fix -Wsign-compare warning in std::string::resize_for_overwrite Date: Fri, 27 Sep 2024 21:41:54 +0100 Message-ID: <20240927204207.2349486-1-jwakely@redhat.com> 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=-12.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham 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 -- libstdc++-v3/ChangeLog: * include/bits/basic_string.tcc (resize_for_overwrite): Fix -Wsign-compare warning. * include/bits/cow_string.h (resize_for_overwrite): Likewise. --- libstdc++-v3/include/bits/basic_string.tcc | 2 +- libstdc++-v3/include/bits/cow_string.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc index 2c17d258bfe..caeddaf2f5b 100644 --- a/libstdc++-v3/include/bits/basic_string.tcc +++ b/libstdc++-v3/include/bits/basic_string.tcc @@ -611,7 +611,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static_assert(__gnu_cxx::__is_integer_nonstrict::__value, "resize_and_overwrite operation must return an integer"); #endif - _GLIBCXX_DEBUG_ASSERT(__r >= 0 && __r <= __n); + _GLIBCXX_DEBUG_ASSERT(__r >= 0 && size_type(__r) <= __n); __term._M_r = size_type(__r); if (__term._M_r > __n) __builtin_unreachable(); diff --git a/libstdc++-v3/include/bits/cow_string.h b/libstdc++-v3/include/bits/cow_string.h index b78aa74fbfa..087ddf81dd8 100644 --- a/libstdc++-v3/include/bits/cow_string.h +++ b/libstdc++-v3/include/bits/cow_string.h @@ -3800,7 +3800,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static_assert(__gnu_cxx::__is_integer_nonstrict::__value, "resize_and_overwrite operation must return an integer"); #endif - _GLIBCXX_DEBUG_ASSERT(__r >= 0 && __r <= __n); + _GLIBCXX_DEBUG_ASSERT(__r >= 0 && size_type(__r) <= __n); __term._M_r = size_type(__r); if (__term._M_r > __n) __builtin_unreachable();