From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>,
"libstdc++" <libstdc++@gcc.gnu.org>
Subject: Re: [PATCH 1/3] libstdc++: Fix zip_view's operator- for integer-class difference type [PR106766]
Date: Fri, 9 Sep 2022 19:26:07 +0100 [thread overview]
Message-ID: <CAH6eHdR260E=HdxUr0L-5Mth_nY2m9pUcBMyw2A=ZGRXDQPkWA@mail.gmail.com> (raw)
In-Reply-To: <20220909172446.1546805-1-ppalka@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2969 bytes --]
On Fri, 9 Sep 2022, 18:25 Patrick Palka via Libstdc++, <
libstdc++@gcc.gnu.org> wrote:
> make_unsigned_t can't give us the unsigned version of an integer-class
> difference type, so use __make_unsigned_like_t / __to_unsigned_like
> instead.
>
OK, thanks
> PR libstdc++/106766
>
> libstdc++-v3/ChangeLog:
>
> * include/std/ranges (zip_view::_Iterator::operator-): Use
> __to_unsigned_like instead of make_unsigned_t.
> (zip_view::_Sentinel::operator-): Likewise.
> * testsuite/std/ranges/zip/1.cc (test04): New test.
> ---
> libstdc++-v3/include/std/ranges | 8 ++++----
> libstdc++-v3/testsuite/std/ranges/zip/1.cc | 14 ++++++++++++++
> 2 files changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/libstdc++-v3/include/std/ranges
> b/libstdc++-v3/include/std/ranges
> index 2b5cb0531f0..2b8fec3c386 100644
> --- a/libstdc++-v3/include/std/ranges
> +++ b/libstdc++-v3/include/std/ranges
> @@ -4657,8 +4657,8 @@ namespace views::__adaptor
> return ranges::min({difference_type(std::get<_Is>(__x._M_current)
> -
> std::get<_Is>(__y._M_current))...},
> ranges::less{},
> - [](difference_type __i) ->
> make_unsigned_t<difference_type> {
> - return __i < 0 ? -__i : __i;
> + [](difference_type __i) {
> + return __detail::__to_unsigned_like(__i < 0 ?
> -__i : __i);
> });
> }(make_index_sequence<sizeof...(_Vs)>{});
> }
> @@ -4726,8 +4726,8 @@ namespace views::__adaptor
> return [&]<size_t... _Is>(index_sequence<_Is...>) {
> return ranges::min({_Ret(std::get<_Is>(__x._M_current) -
> std::get<_Is>(__y._M_end))...},
> ranges::less{},
> - [](_Ret __i) -> make_unsigned_t<_Ret> {
> - return __i < 0 ? -__i : __i;
> + [](_Ret __i) {
> + return __detail::__to_unsigned_like(__i < 0 ?
> -__i : __i);
> });
> }(make_index_sequence<sizeof...(_Vs)>{});
> }
> diff --git a/libstdc++-v3/testsuite/std/ranges/zip/1.cc
> b/libstdc++-v3/testsuite/std/ranges/zip/1.cc
> index 0113efdb537..f868c97cb69 100644
> --- a/libstdc++-v3/testsuite/std/ranges/zip/1.cc
> +++ b/libstdc++-v3/testsuite/std/ranges/zip/1.cc
> @@ -102,10 +102,24 @@ test03()
> return true;
> }
>
> +constexpr bool
> +test04()
> +{
> + // PR libstdc++/106766
> + auto r = views::zip(views::iota(__int128(0), __int128(1)));
> + auto i = r.begin();
> + auto s = r.end();
> + VERIFY( s - i == 1 );
> + VERIFY( i + 1 - i == 1 );
> +
> + return true;
> +}
> +
> int
> main()
> {
> static_assert(test01());
> static_assert(test02());
> static_assert(test03());
> + static_assert(test04());
> }
> --
> 2.37.3.518.g79f2338b37
>
>
prev parent reply other threads:[~2022-09-09 18:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-09 17:24 Patrick Palka
2022-09-09 17:24 ` [PATCH 2/3] libstdc++: Fix typo in adjacent_view::_Iterator [PR106798] Patrick Palka
2022-09-09 18:26 ` Jonathan Wakely
2022-09-09 17:24 ` [PATCH 3/3] libstdc++: Fix return type of empty zip/adjacent_transform [PR106803] Patrick Palka
2022-09-09 18:29 ` Jonathan Wakely
2022-09-09 18:26 ` Jonathan Wakely [this message]
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='CAH6eHdR260E=HdxUr0L-5Mth_nY2m9pUcBMyw2A=ZGRXDQPkWA@mail.gmail.com' \
--to=jwakely.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
--cc=ppalka@redhat.com \
/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).