[2/3] libstdc++: Fix typo in adjacent_view::_Iterator [PR106798]

Message ID 20220909172446.1546805-2-ppalka@redhat.com
State New, archived
Headers
Series [1/3] libstdc++: Fix zip_view's operator- for integer-class difference type [PR106766] |

Commit Message

Patrick Palka Sept. 9, 2022, 5:24 p.m. UTC
  PR libstdc++/106798

libstdc++-v3/ChangeLog:

	* include/std/ranges (adjacent_view::_Iterator::_Iterator): Fix
	typo.
	* testsuite/std/ranges/adaptors/adjacent/1.cc (test04): New test.
---
 libstdc++-v3/include/std/ranges                      |  2 +-
 .../testsuite/std/ranges/adaptors/adjacent/1.cc      | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
  

Comments

Jonathan Wakely Sept. 9, 2022, 6:26 p.m. UTC | #1
On Fri, 9 Sep 2022, 18:25 Patrick Palka via Libstdc++, <
libstdc++@gcc.gnu.org> wrote:

>         PR libstdc++/106798
>
> libstdc++-v3/ChangeLog:
>
>         * include/std/ranges (adjacent_view::_Iterator::_Iterator): Fix
>         typo.
>         * testsuite/std/ranges/adaptors/adjacent/1.cc (test04): New test.
>



OK, thanks.


---
>  libstdc++-v3/include/std/ranges                      |  2 +-
>  .../testsuite/std/ranges/adaptors/adjacent/1.cc      | 12 ++++++++++++
>  2 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/libstdc++-v3/include/std/ranges
> b/libstdc++-v3/include/std/ranges
> index 2b8fec3c386..37ad80ad3de 100644
> --- a/libstdc++-v3/include/std/ranges
> +++ b/libstdc++-v3/include/std/ranges
> @@ -5239,7 +5239,7 @@ namespace views::__adaptor
>        requires _Const && convertible_to<iterator_t<_Vp>,
> iterator_t<_Base>>
>      {
>        for (size_t __j = 0; __j < _Nm; ++__j)
> -       _M_current[__j] = std::move(__i[__j]);
> +       _M_current[__j] = std::move(__i._M_current[__j]);
>      }
>
>      constexpr auto
> diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc
> b/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc
> index 9829f79364f..443c1fbf450 100644
> --- a/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc
> +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc
> @@ -101,10 +101,22 @@ test03()
>    return true;
>  }
>
> +constexpr bool
> +test04()
> +{
> +  // PR libstdc++/106798
> +  auto r = views::single(0) | views::lazy_split(0) | views::pairwise;
> +  decltype(ranges::cend(r)) s = r.end();
> +  VERIFY( r.begin() == s );
> +
> +  return true;
> +}
> +
>  int
>  main()
>  {
>    static_assert(test01());
>    static_assert(test02());
>    static_assert(test03());
> +  static_assert(test04());
>  }
> --
> 2.37.3.518.g79f2338b37
>
>
  

Patch

diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 2b8fec3c386..37ad80ad3de 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -5239,7 +5239,7 @@  namespace views::__adaptor
       requires _Const && convertible_to<iterator_t<_Vp>, iterator_t<_Base>>
     {
       for (size_t __j = 0; __j < _Nm; ++__j)
-	_M_current[__j] = std::move(__i[__j]);
+	_M_current[__j] = std::move(__i._M_current[__j]);
     }
 
     constexpr auto
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc
index 9829f79364f..443c1fbf450 100644
--- a/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc
@@ -101,10 +101,22 @@  test03()
   return true;
 }
 
+constexpr bool
+test04()
+{
+  // PR libstdc++/106798
+  auto r = views::single(0) | views::lazy_split(0) | views::pairwise;
+  decltype(ranges::cend(r)) s = r.end();
+  VERIFY( r.begin() == s );
+
+  return true;
+}
+
 int
 main()
 {
   static_assert(test01());
   static_assert(test02());
   static_assert(test03());
+  static_assert(test04());
 }