From 10a32d479861c3a39987d3468f6a400e907499a2 Mon Sep 17 00:00:00 2001 From: Patrick Palka Date: Thu, 27 Feb 2020 10:35:08 -0500 Subject: [PATCH] libstdc++: -D_GLIBCXX_DEBUG fixes in the constrained algos tests This fixes the failures in the constrained algos tests when they are run in debug mode. libstdc++-v3/ChangeLog: * testsuite/25_algorithms/copy/constrained.cc: Don't assume that the base() of a vector<>::iterator is a pointer. * testsuite/25_algorithms/copy_backward/constrained.cc: Likewise. * testsuite/25_algorithms/move/constrained.cc: Likewise. * testsuite/25_algorithms/move_backward/constrained.cc: Likewise. * testsuite/25_algorithms/inplace_merge/constrained.cc: Use foo.data() instead of &foo[0]. * testsuite/25_algorithms/partial_sort/constrained.cc: Likewise. * testsuite/25_algorithms/partial_sort_copy/constrained.cc: Likewise. * testsuite/25_algorithms/shuffle/constrained.cc: Likewise. * testsuite/25_algorithms/sort/constrained.cc: Likewise. * testsuite/25_algorithms/stable_sort/constrained.cc: Likewise. --- libstdc++-v3/ChangeLog | 15 +++++++++++++++ libstdc++-v3/testsuite/25_algorithms/copy/constrained.cc | 16 ++++++++-------- .../testsuite/25_algorithms/copy_backward/constrained.cc | 16 ++++++++-------- .../testsuite/25_algorithms/inplace_merge/constrained.cc | 2 +- libstdc++-v3/testsuite/25_algorithms/move/constrained.cc | 16 ++++++++-------- .../testsuite/25_algorithms/move_backward/constrained.cc | 16 ++++++++-------- .../testsuite/25_algorithms/partial_sort/constrained.cc | 4 ++-- .../25_algorithms/partial_sort_copy/constrained.cc | 8 ++++---- .../testsuite/25_algorithms/shuffle/constrained.cc | 4 ++-- libstdc++-v3/testsuite/25_algorithms/sort/constrained.cc | 4 ++-- .../testsuite/25_algorithms/stable_sort/constrained.cc | 4 ++-- 11 files changed, 60 insertions(+), 45 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index bd76b54..b3efeae 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,18 @@ +2020-02-27 Patrick Palka + + * testsuite/25_algorithms/copy/constrained.cc: Don't assume that the + base() of a vector<>::iterator is a pointer. + * testsuite/25_algorithms/copy_backward/constrained.cc: Likewise. + * testsuite/25_algorithms/move/constrained.cc: Likewise. + * testsuite/25_algorithms/move_backward/constrained.cc: Likewise. + * testsuite/25_algorithms/inplace_merge/constrained.cc: Use foo.data() + instead of &foo[0]. + * testsuite/25_algorithms/partial_sort/constrained.cc: Likewise. + * testsuite/25_algorithms/partial_sort_copy/constrained.cc: Likewise. + * testsuite/25_algorithms/shuffle/constrained.cc: Likewise. + * testsuite/25_algorithms/sort/constrained.cc: Likewise. + * testsuite/25_algorithms/stable_sort/constrained.cc: Likewise. + 2020-02-27 Jonathan Wakely * include/debug/array (operator<=>): Define for C++20. diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/constrained.cc b/libstdc++-v3/testsuite/25_algorithms/copy/constrained.cc index 85f7d64..aafe845 100644 --- a/libstdc++-v3/testsuite/25_algorithms/copy/constrained.cc +++ b/libstdc++-v3/testsuite/25_algorithms/copy/constrained.cc @@ -70,8 +70,8 @@ test01() std::vector y(3); const int z[3] = { 1, 2, 3 }; auto [in, out] = ranges::copy(x, ranges::begin(y)); - VERIFY( in.base() == x.data()+3 ); - VERIFY( out.base() == y.data()+3 ); + VERIFY( in == x.begin()+3 ); + VERIFY( out == y.begin()+3 ); VERIFY( ranges::equal(y, z) && ranges::equal(x, z) ); } @@ -81,8 +81,8 @@ test01() std::vector y(3); const int z[3] = { 1, 2, 3 }; auto [in, out] = ranges::copy(x, ranges::begin(y)); - VERIFY( in.base() == x.data()+3 ); - VERIFY( out.base() == y.data()+3 ); + VERIFY( in == x.begin()+3 ); + VERIFY( out == y.begin()+3 ); VERIFY( ranges::equal(y, z) && ranges::equal(x, z) ); } @@ -93,8 +93,8 @@ test01() auto [in,out] = ranges::copy(make_reverse_iterator(x.end()), make_reverse_iterator(x.begin()), make_reverse_iterator(y.end())); - VERIFY( in.base().base() == x.data()+3 ); - VERIFY( out.base().base() == y.data() ); + VERIFY( in.base() == x.begin()+3 ); + VERIFY( out.base() == y.begin() ); VERIFY( ranges::equal(y, z) && ranges::equal(x, z) ); } @@ -105,8 +105,8 @@ test01() auto [in,out] = ranges::copy(make_reverse_iterator(x.end()), make_reverse_iterator(x.begin()), make_reverse_iterator(y.end())); - VERIFY( in.base().base() == x.data()+3 ); - VERIFY( out.base().base() == y.data() ); + VERIFY( in.base() == x.begin()+3 ); + VERIFY( out.base() == y.begin() ); VERIFY( ranges::equal(y, z) && ranges::equal(x, z) ); } } diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_backward/constrained.cc b/libstdc++-v3/testsuite/25_algorithms/copy_backward/constrained.cc index 900f78a..9df2a2f 100644 --- a/libstdc++-v3/testsuite/25_algorithms/copy_backward/constrained.cc +++ b/libstdc++-v3/testsuite/25_algorithms/copy_backward/constrained.cc @@ -57,8 +57,8 @@ test01() std::vector y(3); const int z[3] = { 1, 2, 3 }; auto [in, out] = ranges::copy_backward(x, ranges::end(y)); - VERIFY( in.base() == x.data()+3 ); - VERIFY( out.base() == y.data() ); + VERIFY( in == x.begin()+3 ); + VERIFY( out == y.begin() ); VERIFY( ranges::equal(y, z) && ranges::equal(x, z) ); } @@ -68,8 +68,8 @@ test01() std::vector y(3); const int z[3] = { 1, 2, 3 }; auto [in, out] = ranges::copy_backward(x, ranges::end(y)); - VERIFY( in.base() == x.data()+3 ); - VERIFY( out.base() == y.data() ); + VERIFY( in == x.begin()+3 ); + VERIFY( out == y.begin() ); VERIFY( ranges::equal(y, z) && ranges::equal(x, z) ); } @@ -80,8 +80,8 @@ test01() auto [in,out] = ranges::copy_backward(make_reverse_iterator(x.end()), make_reverse_iterator(x.begin()), make_reverse_iterator(y.begin())); - VERIFY( in.base().base() == x.data()+3 ); - VERIFY( out.base().base() == y.data()+3 ); + VERIFY( in.base() == x.begin()+3 ); + VERIFY( out.base() == y.begin()+3 ); VERIFY( ranges::equal(y, z) && ranges::equal(x, z) ); } @@ -92,8 +92,8 @@ test01() auto [in,out] = ranges::copy_backward(make_reverse_iterator(x.end()), make_reverse_iterator(x.begin()), make_reverse_iterator(y.begin())); - VERIFY( in.base().base() == x.data()+3 ); - VERIFY( out.base().base() == y.data()+3 ); + VERIFY( in.base() == x.begin()+3 ); + VERIFY( out.base() == y.begin()+3 ); VERIFY( ranges::equal(y, z) && ranges::equal(x, z) ); } } diff --git a/libstdc++-v3/testsuite/25_algorithms/inplace_merge/constrained.cc b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/constrained.cc index 8560568..e6e16c8 100644 --- a/libstdc++-v3/testsuite/25_algorithms/inplace_merge/constrained.cc +++ b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/constrained.cc @@ -40,7 +40,7 @@ test01() v.insert(v.end(), x, x+j); ranges::sort(v); - test_range rz(&v[0], &v[0]+i+j); + test_range rz(v.data(), v.data()+i+j); auto result = ranges::inplace_merge(rz, next(ranges::begin(rz), i)); VERIFY( result == rz.end() ); diff --git a/libstdc++-v3/testsuite/25_algorithms/move/constrained.cc b/libstdc++-v3/testsuite/25_algorithms/move/constrained.cc index d205b35..f15de54 100644 --- a/libstdc++-v3/testsuite/25_algorithms/move/constrained.cc +++ b/libstdc++-v3/testsuite/25_algorithms/move/constrained.cc @@ -99,8 +99,8 @@ test01() std::vector y(3); const int z[3] = { 1, 2, 3 }; auto [in, out] = ranges::move(x, ranges::begin(y)); - VERIFY( in.base() == x.data()+3 ); - VERIFY( out.base() == y.data()+3 ); + VERIFY( in == x.begin()+3 ); + VERIFY( out == y.begin()+3 ); VERIFY( ranges::equal(y, z) && ranges::equal(x, z) ); } @@ -110,8 +110,8 @@ test01() std::vector y(3); const int z[3] = { 1, 2, 3 }; auto [in, out] = ranges::move(x, ranges::begin(y)); - VERIFY( in.base() == x.data()+3 ); - VERIFY( out.base() == y.data()+3 ); + VERIFY( in == x.begin()+3 ); + VERIFY( out == y.begin()+3 ); VERIFY( ranges::equal(y, z) && ranges::equal(x, z) ); } @@ -122,8 +122,8 @@ test01() auto [in,out] = ranges::move(make_reverse_iterator(x.end()), make_reverse_iterator(x.begin()), make_reverse_iterator(y.end())); - VERIFY( in.base().base() == x.data()+3 ); - VERIFY( out.base().base() == y.data() ); + VERIFY( in.base() == x.begin()+3 ); + VERIFY( out.base() == y.begin() ); VERIFY( ranges::equal(y, z) && ranges::equal(x, z) ); } @@ -134,8 +134,8 @@ test01() auto [in,out] = ranges::move(make_reverse_iterator(x.end()), make_reverse_iterator(x.begin()), make_reverse_iterator(y.end())); - VERIFY( in.base().base() == x.data()+3 ); - VERIFY( out.base().base() == y.data() ); + VERIFY( in.base() == x.begin()+3 ); + VERIFY( out.base() == y.begin() ); VERIFY( ranges::equal(y, z) && ranges::equal(x, z) ); } } diff --git a/libstdc++-v3/testsuite/25_algorithms/move_backward/constrained.cc b/libstdc++-v3/testsuite/25_algorithms/move_backward/constrained.cc index 3c4aa5d..14f2155 100644 --- a/libstdc++-v3/testsuite/25_algorithms/move_backward/constrained.cc +++ b/libstdc++-v3/testsuite/25_algorithms/move_backward/constrained.cc @@ -86,8 +86,8 @@ test01() std::vector y(3); const int z[3] = { 1, 2, 3 }; auto [in, out] = ranges::move_backward(x, ranges::end(y)); - VERIFY( in.base() == x.data()+3 ); - VERIFY( out.base() == y.data() ); + VERIFY( in == x.begin()+3 ); + VERIFY( out == y.begin() ); VERIFY( ranges::equal(y, z) && ranges::equal(x, z) ); } @@ -97,8 +97,8 @@ test01() std::vector y(3); const int z[3] = { 1, 2, 3 }; auto [in, out] = ranges::move_backward(x, ranges::end(y)); - VERIFY( in.base() == x.data()+3 ); - VERIFY( out.base() == y.data() ); + VERIFY( in == x.begin()+3 ); + VERIFY( out == y.begin() ); VERIFY( ranges::equal(y, z) && ranges::equal(x, z) ); } @@ -109,8 +109,8 @@ test01() auto [in,out] = ranges::move_backward(make_reverse_iterator(x.end()), make_reverse_iterator(x.begin()), make_reverse_iterator(y.begin())); - VERIFY( in.base().base() == x.data()+3 ); - VERIFY( out.base().base() == y.data()+3 ); + VERIFY( in.base() == x.begin()+3 ); + VERIFY( out.base() == y.begin()+3 ); VERIFY( ranges::equal(y, z) && ranges::equal(x, z) ); } @@ -121,8 +121,8 @@ test01() auto [in,out] = ranges::move_backward(make_reverse_iterator(x.end()), make_reverse_iterator(x.begin()), make_reverse_iterator(y.begin())); - VERIFY( in.base().base() == x.data()+3 ); - VERIFY( out.base().base() == y.data()+3 ); + VERIFY( in.base() == x.begin()+3 ); + VERIFY( out.base() == y.begin()+3 ); VERIFY( ranges::equal(y, z) && ranges::equal(x, z) ); } } diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort/constrained.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort/constrained.cc index 430e3c0..3b61fe7 100644 --- a/libstdc++-v3/testsuite/25_algorithms/partial_sort/constrained.cc +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort/constrained.cc @@ -40,9 +40,9 @@ test01() std::iota(vref.begin(), vref.end(), 0); std::vector v1(vref), v2(vref); test_container c - = {&v1[0], &v1[0] + size}; + = {v1.data(), v1.data() + size}; test_range r - = {&v2[0], &v2[0] + size}; + = {v2.data(), v2.data() + size}; std::ranlux48_base g1(size), g2(size + 1); ranges::shuffle(c, g1); diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/constrained.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/constrained.cc index 6b586f8..519c41f 100644 --- a/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/constrained.cc +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/constrained.cc @@ -49,15 +49,15 @@ test01() for (unsigned middle = 0; middle < 10; ++middle) { test_container c - = {&v1[0], &v1[0] + size}; + = {v1.data(), v1.data() + size}; test_range r - = {&v2[0], &v2[0] + size}; + = {v2.data(), v2.data() + size}; std::vector o1(middle), o2(middle); test_range w1 - = {&o1[0], &o1[0]+middle}; + = {o1.data(), o1.data()+middle}; test_range w2 - = {&o2[0], &o2[0]+middle}; + = {o2.data(), o2.data()+middle}; auto [in1, out1] = ranges::partial_sort_copy(c.begin(), c.end(), w1.begin(), w1.end(), diff --git a/libstdc++-v3/testsuite/25_algorithms/shuffle/constrained.cc b/libstdc++-v3/testsuite/25_algorithms/shuffle/constrained.cc index b96343a..3f97600 100644 --- a/libstdc++-v3/testsuite/25_algorithms/shuffle/constrained.cc +++ b/libstdc++-v3/testsuite/25_algorithms/shuffle/constrained.cc @@ -42,9 +42,9 @@ test01() std::iota(vref.begin(), vref.end(), 0); std::vector v1(vref), v2(vref); test_container c - = {&v1[0], &v1[0] + size}; + = {v1.data(), v1.data() + size}; test_range r - = {&v2[0], &v2[0] + size}; + = {v2.data(), v2.data() + size}; std::ranlux48_base g1(size), g2(size + 1); VERIFY( ranges::shuffle(c, g1) == c.end() ); diff --git a/libstdc++-v3/testsuite/25_algorithms/sort/constrained.cc b/libstdc++-v3/testsuite/25_algorithms/sort/constrained.cc index d822777..b5a99b7 100644 --- a/libstdc++-v3/testsuite/25_algorithms/sort/constrained.cc +++ b/libstdc++-v3/testsuite/25_algorithms/sort/constrained.cc @@ -40,9 +40,9 @@ test01() std::iota(vref.begin(), vref.end(), 0); std::vector v1(vref), v2(vref); test_container c - = {&v1[0], &v1[0] + size}; + = {v1.data(), v1.data() + size}; test_range r - = {&v2[0], &v2[0] + size}; + = {v2.data(), v2.data() + size}; std::ranlux48_base g1(size), g2(size + 1); ranges::shuffle(c, g1); diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_sort/constrained.cc b/libstdc++-v3/testsuite/25_algorithms/stable_sort/constrained.cc index 23a8c03..ef02cca 100644 --- a/libstdc++-v3/testsuite/25_algorithms/stable_sort/constrained.cc +++ b/libstdc++-v3/testsuite/25_algorithms/stable_sort/constrained.cc @@ -44,9 +44,9 @@ test01() std::iota(vref.begin(), vref.end(), 0); std::vector v1(vref), v2(vref); test_container c - = {&v1[0], &v1[0] + size}; + = {v1.data(), v1.data() + size}; test_range r - = {&v2[0], &v2[0] + size}; + = {v2.data(), v2.data() + size}; std::ranlux48_base g1(size), g2(size + 1); ranges::shuffle(c, g1); -- 2.7.4