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 217AD3852C53 for ; Mon, 28 Nov 2022 17:00:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 217AD3852C53 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=1669654824; 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=aZ9rbiaO6yF1z6G66eh4tKnrSQLpVcp1xdxKIwMUY7A=; b=UTVI0bCqXEZeIcEIpOM5U7Zx7kC+/kKIXpljGN2LNlqlSJyW6fKIvACtbOI1Zblcna5j+0 ly8Qc0tT278G3nezuM2FtxMkkZwZ1/uf/HTbMvDCLhBkq6Ac/VKrK3oMP5lZtstxh6XHYI H6qm9Ryw1ynrgVyE55nhNLz9UVO36Ew= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-448-X9F4yKk6ODeYjvpfVucPYg-1; Mon, 28 Nov 2022 12:00:23 -0500 X-MC-Unique: X9F4yKk6ODeYjvpfVucPYg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3547F3C0D860; Mon, 28 Nov 2022 17:00:23 +0000 (UTC) Received: from localhost (unknown [10.33.36.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id F213240C6EC2; Mon, 28 Nov 2022 17:00:22 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Fix std::string_view for I32LP16 targets Date: Mon, 28 Nov 2022 17:00:20 +0000 Message-Id: <20221128170020.61434-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.2 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=ham 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, built on msp430-elf and h8300-elf. Pushed to trunk. -- >8 -- For H8/300 with -msx -mn -mint32 the type of (_M_len - __pos) is int, because int is wider than size_t so the operands are promoted. libstdc++-v3/ChangeLog: * include/std/string_view (basic_string_view::copy) Use explicit template argument for call to std::min. (basic_string_view::substr): Likewise. --- libstdc++-v3/include/std/string_view | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view index 2604af2e9aa..f42045dd6f1 100644 --- a/libstdc++-v3/include/std/string_view +++ b/libstdc++-v3/include/std/string_view @@ -315,7 +315,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { __glibcxx_requires_string_len(__str, __n); __pos = std::__sv_check(size(), __pos, "basic_string_view::copy"); - const size_type __rlen = std::min(__n, _M_len - __pos); + const size_type __rlen = std::min(__n, _M_len - __pos); // _GLIBCXX_RESOLVE_LIB_DEFECTS // 2777. basic_string_view::copy should use char_traits::copy traits_type::copy(__str, data() + __pos, __rlen); @@ -327,7 +327,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION substr(size_type __pos = 0, size_type __n = npos) const noexcept(false) { __pos = std::__sv_check(size(), __pos, "basic_string_view::substr"); - const size_type __rlen = std::min(__n, _M_len - __pos); + const size_type __rlen = std::min(__n, _M_len - __pos); return basic_string_view{_M_str + __pos, __rlen}; } -- 2.38.1