]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix std::string_view for IL32P16 targets
authorJonathan Wakely <jwakely@redhat.com>
Mon, 28 Nov 2022 12:16:21 +0000 (12:16 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 7 Oct 2024 08:55:21 +0000 (09:55 +0100)
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.

libstdc++-v3/include/std/string_view

index 9ee888363813c1536414107a5e91a48ade918b92..23383f578e5e02d49d8fb7051fddffdec0a3e481 100644 (file)
@@ -299,7 +299,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);
@@ -310,7 +310,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};
       }