From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id DE1D93853D49 for ; Sat, 19 Nov 2022 15:08:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DE1D93853D49 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668870533; 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=P0gcfhQStAiihWadtUsB0tI9pCnrwh+UUgLq21dMvuQ=; b=LixQnTsxlZdRhhFrDmfRFR3G7L5wAB3OnO10PotpK/lNwJA9RdWnnHNt4UX5C3Wn8oYlgh eNK8v2u/WBSlq07GW0cQlXjwuePE4/R0RcxoHmBRqdGP9oeZYQ6wUufvk0PxO4vKNwd0KB dp1biPBwqx6jl1aApa1YUEdAjGiTOks= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-616-Ih6SD1QZPgS1FtsYN6h-qA-1; Sat, 19 Nov 2022 10:08:50 -0500 X-MC-Unique: Ih6SD1QZPgS1FtsYN6h-qA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 43F6385A59D; Sat, 19 Nov 2022 15:08:50 +0000 (UTC) Received: from localhost (unknown [10.33.36.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E9B517582; Sat, 19 Nov 2022 15:08:49 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Fix -Wsign-compare warnings in std::format Date: Sat, 19 Nov 2022 15:08:47 +0000 Message-Id: <20221119150847.1673947-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.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_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tested x86_64-linux. Pushed to trunk. -- >8 -- libstdc++-v3/ChangeLog: * include/std/format: Fix -Wsign-compare warnings. --- libstdc++-v3/include/std/format | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format index f4fc85a16d2..561ae161d16 100644 --- a/libstdc++-v3/include/std/format +++ b/libstdc++-v3/include/std/format @@ -291,7 +291,7 @@ namespace __format } else { - constexpr size_t __n = 32; + constexpr int __n = 32; char __buf[__n]{}; for (int __i = 0; __i < __n && __first != __last; ++__i) __buf[__i] = __first[__i]; @@ -1544,7 +1544,7 @@ namespace __format if (size_t __extras = int(__d == __p) + __z) { - if (__dynbuf.empty() && __extras <= (__end - __res.ptr)) + if (__dynbuf.empty() && __extras <= size_t(__end - __res.ptr)) { // Move exponent to make space for extra chars. __builtin_memmove(__start + __p + __extras, @@ -2357,7 +2357,7 @@ namespace __format _M_write(_CharT __c) { *_M_next++ = __c; - if (_M_next - _M_span.begin() == _M_span.size()) [[unlikely]] + if (_M_next - _M_span.begin() == std::ssize(_M_span)) [[unlikely]] _M_overflow(); } @@ -2469,7 +2469,7 @@ namespace __format auto __used = this->_M_used(); if (_M_max < 0) // No maximum. _M_out = ranges::copy(__used, std::move(_M_out)).out; - else if (_M_count < _M_max) + else if (_M_count < size_t(_M_max)) { auto __max = _M_max - _M_count; span<_CharT> __first; -- 2.38.1