From: Jonathan Wakely <jwakely@redhat.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org
Subject: Re: [PATCH] libstdc++: Fix typo in stride_view's operator- [PR107313]
Date: Wed, 19 Oct 2022 17:51:00 +0100 [thread overview]
Message-ID: <CACb0b4kSYodW7Jx9C=JYtFw8jmPGY40S3D8FNXJTN2D0_rpYuA@mail.gmail.com> (raw)
In-Reply-To: <20221019143141.248710-1-ppalka@redhat.com>
On Wed, 19 Oct 2022 at 15:33, Patrick Palka via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> PR libstdc++/107313
OK
>
> libstdc++-v3/ChangeLog:
>
> * include/std/ranges (stride_view::_Iterator::operator-): Fix typo.
> * testsuite/std/ranges/adaptors/stride/1.cc (test03): New test.
> ---
> libstdc++-v3/include/std/ranges | 2 +-
> .../testsuite/std/ranges/adaptors/stride/1.cc | 20 +++++++++++++++++++
> 2 files changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
> index d113cf19dc7..b29264931cc 100644
> --- a/libstdc++-v3/include/std/ranges
> +++ b/libstdc++-v3/include/std/ranges
> @@ -7874,7 +7874,7 @@ namespace views::__adaptor
> friend constexpr difference_type
> operator-(default_sentinel_t __y, const _Iterator& __x)
> requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<_Base>>
> - { return __detail::__div_ceil(__x._M_end, __x._M_current, __x._M_stride); }
> + { return __detail::__div_ceil(__x._M_end - __x._M_current, __x._M_stride); }
>
> friend constexpr difference_type
> operator-(const _Iterator& __x, default_sentinel_t __y)
> diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc
> index 745d1a61c1b..37ae896014a 100644
> --- a/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc
> +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/stride/1.cc
> @@ -64,10 +64,30 @@ test02()
> VERIFY( ranges::equal(v, (int[]){1, 4, 7}) );
> }
>
> +void
> +test03()
> +{
> + // PR libstdc++/107313
> + int x[] = {1, 2, 3, 4, 5};
> + __gnu_test::test_input_range<int> rx(x);
> + auto r = views::counted(rx.begin(), 4) | views::stride(2);
> + auto i = r.begin();
> + std::default_sentinel_t s = r.end();
> + VERIFY( s != i );
> + VERIFY( s - i == 2 && i - s == -2 );
> + ++i;
> + VERIFY( s != i );
> + VERIFY( s - i == 1 && i - s == -1 );
> + ++i;
> + VERIFY( s == i );
> + VERIFY( s - i == 0 && i - s == 0 );
> +}
> +
> int
> main()
> {
> static_assert(test01());
> test02<__gnu_test::test_input_range<int>>();
> test02<__gnu_test::test_forward_range<int>>();
> + test03();
> }
> --
> 2.38.1.119.g9c32cfb49c
>
prev parent reply other threads:[~2022-10-19 16:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-19 14:31 Patrick Palka
2022-10-19 16:51 ` 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='CACb0b4kSYodW7Jx9C=JYtFw8jmPGY40S3D8FNXJTN2D0_rpYuA@mail.gmail.com' \
--to=jwakely@redhat.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).