[gcc(refs/vendors/ibm/heads/perf)] libstdc++: Fix use of inaccessible private member in split_view (PR93936)
Jiu Fu Guo
guojiufu@gcc.gnu.org
Thu Mar 19 05:54:00 GMT 2020
https://gcc.gnu.org/g:8ce13842b50cbd2676f2e322995182af20df31fe
commit 8ce13842b50cbd2676f2e322995182af20df31fe
Author: Patrick Palka <ppalka@redhat.com>
Date: Wed Feb 26 08:38:06 2020 -0500
libstdc++: Fix use of inaccessible private member in split_view (PR93936)
We are calling _OuterIter::__current from _InnerIter::operator==, but the former
is private within this non-member friend. Fix this by calling
_OuterIter::operator== instead, which does the right thing here.
libstdc++-v3/ChangeLog:
PR libstdc++/93936
* include/std/ranges (split_view::_InnerIter::operator==): Compare
the operands' _M_i rather than their _M_i.current().
* testsuite/std/ranges/adaptors/split.cc: Augment test.
Diff:
---
libstdc++-v3/ChangeLog | 5 +++++
libstdc++-v3/include/std/ranges | 2 +-
libstdc++-v3/testsuite/std/ranges/adaptors/split.cc | 18 ++++++++++++++++++
3 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 8af27d4cc52..49f2b59e3ae 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,10 @@
2020-02-26 Patrick Palka <ppalka@redhat.com>
+ PR libstdc++/93936
+ * include/std/ranges (split_view::_InnerIter::operator==): Compare
+ the operands' _M_i rather than their _M_i.current().
+ * testsuite/std/ranges/adaptors/split.cc: Augment test.
+
P1645R1 constexpr for <numeric> algorithms
* include/bits/stl_numeric.h (iota, accumulate, inner_product,
partial_sum, adjacent_difference): Make conditionally constexpr for
diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index d8326632166..bad89c5b8b0 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -2841,7 +2841,7 @@ namespace views
friend constexpr bool
operator==(const _InnerIter& __x, const _InnerIter& __y)
requires forward_range<_Base>
- { return __x._M_i.__current() == __y._M_i.__current(); }
+ { return __x._M_i == __y._M_i; }
friend constexpr bool
operator==(const _InnerIter& __x, default_sentinel_t)
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/split.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/split.cc
index e25031c0aea..52b015cf0c6 100644
--- a/libstdc++-v3/testsuite/std/ranges/adaptors/split.cc
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/split.cc
@@ -91,6 +91,23 @@ test04()
VERIFY( i == v.end() );
}
+void
+test05()
+{
+ auto as_string = [](ranges::view auto rng) {
+ auto in = rng | views::common;
+ return std::string(in.begin(), in.end());
+ };
+ std::string str
+ = "Now is the time for all good men to come to the aid of their county.";
+ auto rng
+ = str | views::split(' ') | views::transform(as_string) | views::common;
+ std::vector<std::string> words(rng.begin(), rng.end());
+ auto not_space_p = [](char c) { return c != ' '; };
+ VERIFY( ranges::equal(words | views::join,
+ str | views::filter(not_space_p)) );
+}
+
int
main()
{
@@ -98,4 +115,5 @@ main()
test02();
test03();
test04();
+ test05();
}
More information about the Libstdc++-cvs
mailing list