Skip to content

[libc++][test] LWG2593: Moved-from state of Allocators #107344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libcxx/docs/Status/Cxx20Issues.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"Issue #","Issue Name","Meeting","Status","First released version","Notes"
"`LWG2070 <https://wg21.link/LWG2070>`__","``allocate_shared``\ should use ``allocator_traits<A>::construct``\ ","2017-07 (Toronto)","|Nothing To Do|","","Resolved by `P0674R1 <https://wg21.link/P0674R1>`__"
"`LWG2444 <https://wg21.link/LWG2444>`__","Inconsistent complexity for ``std::sort_heap``\ ","2017-07 (Toronto)","|Nothing To Do|","",""
"`LWG2593 <https://wg21.link/LWG2593>`__","Moved-from state of Allocators","2017-07 (Toronto)","","",""
"`LWG2593 <https://wg21.link/LWG2593>`__","Moved-from state of Allocators","2017-07 (Toronto)","|Nothing To Do|","",""
"`LWG2597 <https://wg21.link/LWG2597>`__","``std::log``\ misspecified for complex numbers","2017-07 (Toronto)","","",""
"`LWG2783 <https://wg21.link/LWG2783>`__","``stack::emplace()``\ and ``queue::emplace()``\ should return ``decltype(auto)``\ ","2017-07 (Toronto)","|Complete|","",""
"`LWG2932 <https://wg21.link/LWG2932>`__","Constraints on parallel algorithm implementations are underspecified","2017-07 (Toronto)","","",""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int main(int, char**)
assert(m.size() == 0);
assert(std::distance(m.begin(), m.end()) == 0);

assert(mo.get_allocator() == A(test_alloc_base::moved_value));
assert(mo.get_allocator() == A(7));
assert(mo.key_comp() == C(5));
assert(mo.size() == 0);
assert(std::distance(mo.begin(), mo.end()) == 0);
Expand Down Expand Up @@ -65,7 +65,7 @@ int main(int, char**)
assert(*std::next(m.begin()) == V(2, 1));
assert(*std::next(m.begin(), 2) == V(3, 1));

assert(mo.get_allocator() == A(test_alloc_base::moved_value));
assert(mo.get_allocator() == A(7));
assert(mo.key_comp() == C(5));
assert(mo.size() == 0);
assert(std::distance(mo.begin(), mo.end()) == 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int main(int, char**)
assert(m.size() == 0);
assert(std::distance(m.begin(), m.end()) == 0);

assert(mo.get_allocator() == A(test_alloc_base::moved_value));
assert(mo.get_allocator() == A(7));
assert(mo.key_comp() == C(5));
assert(mo.size() == 0);
assert(std::distance(mo.begin(), mo.end()) == 0);
Expand Down Expand Up @@ -71,7 +71,7 @@ int main(int, char**)
assert(*std::next(m.begin(), 7) == V(3, 1.5));
assert(*std::next(m.begin(), 8) == V(3, 2));

assert(mo.get_allocator() == A(test_alloc_base::moved_value));
assert(mo.get_allocator() == A(7));
assert(mo.key_comp() == C(5));
assert(mo.size() == 0);
assert(std::distance(mo.begin(), mo.end()) == 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int main(int, char**)
assert(m.size() == 0);
assert(std::distance(m.begin(), m.end()) == 0);

assert(mo.get_allocator() == A(test_alloc_base::moved_value));
assert(mo.get_allocator() == A(7));
assert(mo.key_comp() == C(5));
assert(mo.size() == 0);
assert(std::distance(mo.begin(), mo.end()) == 0);
Expand Down Expand Up @@ -72,7 +72,7 @@ int main(int, char**)
assert(*std::next(m.begin(), 7) == 3);
assert(*std::next(m.begin(), 8) == 3);

assert(mo.get_allocator() == A(test_alloc_base::moved_value));
assert(mo.get_allocator() == A(7));
assert(mo.key_comp() == C(5));
assert(mo.size() == 0);
assert(std::distance(mo.begin(), mo.end()) == 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int main(int, char**)
assert(m.size() == 0);
assert(std::distance(m.begin(), m.end()) == 0);

assert(mo.get_allocator() == A(test_alloc_base::moved_value));
assert(mo.get_allocator() == A(7));
assert(mo.key_comp() == C(5));
assert(mo.size() == 0);
assert(std::distance(mo.begin(), mo.end()) == 0);
Expand Down Expand Up @@ -66,7 +66,7 @@ int main(int, char**)
assert(*std::next(m.begin()) == 2);
assert(*std::next(m.begin(), 2) == 3);

assert(mo.get_allocator() == A(test_alloc_base::moved_value));
assert(mo.get_allocator() == A(7));
assert(mo.key_comp() == C(5));
assert(mo.size() == 0);
assert(std::distance(mo.begin(), mo.end()) == 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ void test(int expected_num_allocs = 1) {
assert(alloc_stats.copied == 0);
assert(alloc_stats.moved == num_stored_allocs);
{
const AllocT& a = v.get_allocator();
assert(a.get_id() == test_alloc_base::moved_value);
assert(a.get_data() == test_alloc_base::moved_value);
}
{
const AllocT& a = v2.get_allocator();
assert(a.get_id() == 101);
assert(a.get_data() == 42);
const AllocT& a1 = v.get_allocator();
assert(a1.get_id() == test_alloc_base::moved_value);
assert(a1.get_data() == 42);

const AllocT& a2 = v2.get_allocator();
assert(a2.get_id() == 101);
assert(a2.get_data() == 42);

assert(a1 == a2);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int main(int, char**)
assert(c2 == c3);
assert(c1.size() == 0);
assert(c3.get_allocator() == old_a);
assert(c1.get_allocator() == A(test_alloc_base::moved_value));
assert(c1.get_allocator() == A(1));
LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c1));
LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c2));
LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c3));
Expand Down
17 changes: 9 additions & 8 deletions libcxx/test/std/containers/sequences/vector.bool/move.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,15 @@ TEST_CONSTEXPR_CXX20 bool tests()
assert(alloc_stats.copied == 0);
assert(alloc_stats.moved == 1);
{
const AllocT& a = v.get_allocator();
assert(a.get_id() == test_alloc_base::moved_value);
assert(a.get_data() == test_alloc_base::moved_value);
}
{
const AllocT& a = v2.get_allocator();
assert(a.get_id() == 101);
assert(a.get_data() == 42);
const AllocT& a1 = v.get_allocator();
assert(a1.get_id() == test_alloc_base::moved_value);
assert(a1.get_data() == 42);

const AllocT& a2 = v2.get_allocator();
assert(a2.get_id() == 101);
assert(a2.get_data() == 42);

assert(a1 == a2);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,15 @@ TEST_CONSTEXPR_CXX20 bool tests()
assert(alloc_stats.copied == 0);
assert(alloc_stats.moved == 1);
{
const test_allocator<int>& a = v.get_allocator();
assert(a.get_id() == test_alloc_base::moved_value);
assert(a.get_data() == test_alloc_base::moved_value);
}
{
const test_allocator<int>& a = v2.get_allocator();
assert(a.get_id() == 101);
assert(a.get_data() == 42);
const test_allocator<int>& a1 = v.get_allocator();
assert(a1.get_id() == test_alloc_base::moved_value);
assert(a1.get_data() == 42);

const test_allocator<int>& a2 = v2.get_allocator();
assert(a2.get_id() == 101);
assert(a2.get_data() == 42);

assert(a1 == a2);
}
}

Expand Down
1 change: 0 additions & 1 deletion libcxx/test/support/test_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ class test_allocator {
}
assert(a.data_ != test_alloc_base::destructed_value && a.id_ != test_alloc_base::destructed_value &&
"moving from destroyed allocator");
a.data_ = test_alloc_base::moved_value;
a.id_ = test_alloc_base::moved_value;
}

Expand Down
Loading