public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r13-4370] libstdc++: Fix std::string_view for I32LP16 targets
Date: Mon, 28 Nov 2022 16:57:49 +0000 (GMT)	[thread overview]
Message-ID: <20221128165749.616BD3853D6E@sourceware.org> (raw)

https://gcc.gnu.org/g:a7b97a1f6b9d4993545525fd5cb334ae640ddf45

commit r13-4370-ga7b97a1f6b9d4993545525fd5cb334ae640ddf45
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Nov 28 12:16:21 2022 +0000

    libstdc++: Fix std::string_view for I32LP16 targets
    
    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<size_t>.
            (basic_string_view::substr): Likewise.

Diff:
---
 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<size_t>(__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<size_t>(__n, _M_len - __pos);
 	return basic_string_view{_M_str + __pos, __rlen};
       }

                 reply	other threads:[~2022-11-28 16:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221128165749.616BD3853D6E@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).