diff options
author | Patrick Palka <ppalka@redhat.com> | 2025-03-05 11:11:35 -0500 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2025-03-05 11:11:35 -0500 |
commit | 81c6c99efa6a7afd3082785a9ab7fb64d2c93e1d (patch) | |
tree | ed7f55f41cea6fe6f4e4d9e41e9feab968069fab /libstdc++-v3/testsuite/std/ranges | |
parent | 7439febd94368f42bc46885224e22d2f135fedb2 (diff) | |
download | gcc-81c6c99efa6a7afd3082785a9ab7fb64d2c93e1d.zip gcc-81c6c99efa6a7afd3082785a9ab7fb64d2c93e1d.tar.gz gcc-81c6c99efa6a7afd3082785a9ab7fb64d2c93e1d.tar.bz2 |
libstdc++: Some concat_view bugfixes [PR115215, PR115218, LWG 4082]
- Use __builtin_unreachable to suppress a false-positive "control
reaches end of non-void function" warning in the recursive lambda
(which the existing tests failed to notice since test01 wasn't
being called at runtime)
- Relax the constraints on views::concat in the single-argument case
as per PR115215
- Add an input_range requirement to that same case as per LWG 4082
- In the const-converting constructor of concat_view's iterator,
don't require the first iterator to be default constructible
PR libstdc++/115215
PR libstdc++/115218
libstdc++-v3/ChangeLog:
* include/std/ranges
(concat_view::iterator::_S_invoke_with_runtime_index): Use
__builtin_unreachable in recursive lambda to certify it always
exits via 'return'.
(concat_view::iterator::iterator): In the const-converting
constructor, direct initialize _M_it.
(views::_Concat::operator()): Adjust constraints in the
single-argument case as per LWG 4082.
* testsuite/std/ranges/concat/1.cc (test01): Call it at runtime
too.
(test04): New test.
Reviewed-by: Tomasz KamiĆski <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Diffstat (limited to 'libstdc++-v3/testsuite/std/ranges')
-rw-r--r-- | libstdc++-v3/testsuite/std/ranges/concat/1.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/std/ranges/concat/1.cc b/libstdc++-v3/testsuite/std/ranges/concat/1.cc index e5d10f4..1672191 100644 --- a/libstdc++-v3/testsuite/std/ranges/concat/1.cc +++ b/libstdc++-v3/testsuite/std/ranges/concat/1.cc @@ -85,10 +85,26 @@ test03() VERIFY( ranges::equal(view2, std::vector{4, 5, 6, 1, 2, 3}) ); } +void +test04() +{ + // PR libstdc++/115215 - views::concat rejects non-movable reference + int x[] = {1,2,3}; + struct nomove { + nomove() = default; + nomove(const nomove&) = delete; + }; + auto v = x | views::transform([](int) { return nomove{}; }); + using type = decltype(views::concat(v)); + using type = decltype(v); +} + int main() { static_assert(test01()); + test01(); test02(); test03(); + test04(); } |