aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2021-04-27 14:07:46 -0400
committerPatrick Palka <ppalka@redhat.com>2021-04-27 14:07:46 -0400
commit85ef4b8d4eb3313a48b79c7e752891f9646bb246 (patch)
treedd8c1523f84bc420366f16f48c5d019c1ebb25fb /libstdc++-v3
parentc605a8bf92708e81d771426a87b3baddc32082dd (diff)
downloadgcc-85ef4b8d4eb3313a48b79c7e752891f9646bb246.zip
gcc-85ef4b8d4eb3313a48b79c7e752891f9646bb246.tar.gz
gcc-85ef4b8d4eb3313a48b79c7e752891f9646bb246.tar.bz2
libstdc++: Fix up lambda in join_view::_Iterator::operator++ [PR100290]
Currently, the return type of this lambda is decltype(auto), so the lambda ends up returning a copy of _M_parent->_M_inner rather than a reference to it when _S_ref_glvalue is false. This means _M_inner and ranges::end(__inner_range) are respectively an iterator and sentinel for different ranges, so comparing them is undefined. libstdc++-v3/ChangeLog: PR libstdc++/100290 * include/std/ranges (join_view::_Iterator::operator++): Correct the return type of the lambda to avoid returning a copy of _M_parent->_M_inner. * testsuite/std/ranges/adaptors/join.cc (test10): New test.
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/include/std/ranges2
-rw-r--r--libstdc++-v3/testsuite/std/ranges/adaptors/join.cc11
2 files changed, 12 insertions, 1 deletions
diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 74075a2..09115e9 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -2389,7 +2389,7 @@ namespace views::__adaptor
constexpr _Iterator&
operator++()
{
- auto&& __inner_range = [this] () -> decltype(auto) {
+ auto&& __inner_range = [this] () -> auto&& {
if constexpr (_S_ref_is_glvalue)
return *_M_outer;
else
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/join.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/join.cc
index fb06a76..e6c71d7 100644
--- a/libstdc++-v3/testsuite/std/ranges/adaptors/join.cc
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/join.cc
@@ -160,6 +160,16 @@ test09()
static_assert(!requires { 0 | join; });
}
+void
+test10()
+{
+ // PR libstdc++/100290
+ auto v = views::single(0)
+ | views::transform([](const auto& s) { return views::single(s); })
+ | views::join;
+ VERIFY( ranges::next(v.begin()) == v.end() );
+}
+
int
main()
{
@@ -172,4 +182,5 @@ main()
test07();
test08();
test09();
+ test10();
}