Skip to content

Commit 46a76c3

Browse files
[libc++][test] LWG2593: Moved-from state of Allocators (#107344)
The resolution of LWG2593 didn't require the standard library implementation to change. It merely strengthened requirements on user-defined allocator types and allowed the implementation to make stronger assumptions. The status is tentatively set to Nothing To Do. However, `test_allocator` in libc++'s test suit needs to be fixed to conform to the strengthened requirements. Closes #100220.
1 parent bca2b6d commit 46a76c3

File tree

10 files changed

+37
-35
lines changed

10 files changed

+37
-35
lines changed

libcxx/docs/Status/Cxx20Issues.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"Issue #","Issue Name","Meeting","Status","First released version","Notes"
22
"`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>`__"
33
"`LWG2444 <https://wg21.link/LWG2444>`__","Inconsistent complexity for ``std::sort_heap``\ ","2017-07 (Toronto)","|Nothing To Do|","",""
4-
"`LWG2593 <https://wg21.link/LWG2593>`__","Moved-from state of Allocators","2017-07 (Toronto)","","",""
4+
"`LWG2593 <https://wg21.link/LWG2593>`__","Moved-from state of Allocators","2017-07 (Toronto)","|Nothing To Do|","",""
55
"`LWG2597 <https://wg21.link/LWG2597>`__","``std::log``\ misspecified for complex numbers","2017-07 (Toronto)","","",""
66
"`LWG2783 <https://wg21.link/LWG2783>`__","``stack::emplace()``\ and ``queue::emplace()``\ should return ``decltype(auto)``\ ","2017-07 (Toronto)","|Complete|","",""
77
"`LWG2932 <https://wg21.link/LWG2932>`__","Constraints on parallel algorithm implementations are underspecified","2017-07 (Toronto)","","",""

libcxx/test/std/containers/associative/map/map.cons/move.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int main(int, char**)
3535
assert(m.size() == 0);
3636
assert(std::distance(m.begin(), m.end()) == 0);
3737

38-
assert(mo.get_allocator() == A(test_alloc_base::moved_value));
38+
assert(mo.get_allocator() == A(7));
3939
assert(mo.key_comp() == C(5));
4040
assert(mo.size() == 0);
4141
assert(std::distance(mo.begin(), mo.end()) == 0);
@@ -65,7 +65,7 @@ int main(int, char**)
6565
assert(*std::next(m.begin()) == V(2, 1));
6666
assert(*std::next(m.begin(), 2) == V(3, 1));
6767

68-
assert(mo.get_allocator() == A(test_alloc_base::moved_value));
68+
assert(mo.get_allocator() == A(7));
6969
assert(mo.key_comp() == C(5));
7070
assert(mo.size() == 0);
7171
assert(std::distance(mo.begin(), mo.end()) == 0);

libcxx/test/std/containers/associative/multimap/multimap.cons/move.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int main(int, char**)
3535
assert(m.size() == 0);
3636
assert(std::distance(m.begin(), m.end()) == 0);
3737

38-
assert(mo.get_allocator() == A(test_alloc_base::moved_value));
38+
assert(mo.get_allocator() == A(7));
3939
assert(mo.key_comp() == C(5));
4040
assert(mo.size() == 0);
4141
assert(std::distance(mo.begin(), mo.end()) == 0);
@@ -71,7 +71,7 @@ int main(int, char**)
7171
assert(*std::next(m.begin(), 7) == V(3, 1.5));
7272
assert(*std::next(m.begin(), 8) == V(3, 2));
7373

74-
assert(mo.get_allocator() == A(test_alloc_base::moved_value));
74+
assert(mo.get_allocator() == A(7));
7575
assert(mo.key_comp() == C(5));
7676
assert(mo.size() == 0);
7777
assert(std::distance(mo.begin(), mo.end()) == 0);

libcxx/test/std/containers/associative/multiset/multiset.cons/move.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int main(int, char**)
3535
assert(m.size() == 0);
3636
assert(std::distance(m.begin(), m.end()) == 0);
3737

38-
assert(mo.get_allocator() == A(test_alloc_base::moved_value));
38+
assert(mo.get_allocator() == A(7));
3939
assert(mo.key_comp() == C(5));
4040
assert(mo.size() == 0);
4141
assert(std::distance(mo.begin(), mo.end()) == 0);
@@ -72,7 +72,7 @@ int main(int, char**)
7272
assert(*std::next(m.begin(), 7) == 3);
7373
assert(*std::next(m.begin(), 8) == 3);
7474

75-
assert(mo.get_allocator() == A(test_alloc_base::moved_value));
75+
assert(mo.get_allocator() == A(7));
7676
assert(mo.key_comp() == C(5));
7777
assert(mo.size() == 0);
7878
assert(std::distance(mo.begin(), mo.end()) == 0);

libcxx/test/std/containers/associative/set/set.cons/move.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int main(int, char**)
3535
assert(m.size() == 0);
3636
assert(std::distance(m.begin(), m.end()) == 0);
3737

38-
assert(mo.get_allocator() == A(test_alloc_base::moved_value));
38+
assert(mo.get_allocator() == A(7));
3939
assert(mo.key_comp() == C(5));
4040
assert(mo.size() == 0);
4141
assert(std::distance(mo.begin(), mo.end()) == 0);
@@ -66,7 +66,7 @@ int main(int, char**)
6666
assert(*std::next(m.begin()) == 2);
6767
assert(*std::next(m.begin(), 2) == 3);
6868

69-
assert(mo.get_allocator() == A(test_alloc_base::moved_value));
69+
assert(mo.get_allocator() == A(7));
7070
assert(mo.key_comp() == C(5));
7171
assert(mo.size() == 0);
7272
assert(std::distance(mo.begin(), mo.end()) == 0);

libcxx/test/std/containers/container.requirements/container.requirements.general/allocator_move.pass.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@ void test(int expected_num_allocs = 1) {
5050
assert(alloc_stats.copied == 0);
5151
assert(alloc_stats.moved == num_stored_allocs);
5252
{
53-
const AllocT& a = v.get_allocator();
54-
assert(a.get_id() == test_alloc_base::moved_value);
55-
assert(a.get_data() == test_alloc_base::moved_value);
56-
}
57-
{
58-
const AllocT& a = v2.get_allocator();
59-
assert(a.get_id() == 101);
60-
assert(a.get_data() == 42);
53+
const AllocT& a1 = v.get_allocator();
54+
assert(a1.get_id() == test_alloc_base::moved_value);
55+
assert(a1.get_data() == 42);
56+
57+
const AllocT& a2 = v2.get_allocator();
58+
assert(a2.get_id() == 101);
59+
assert(a2.get_data() == 42);
60+
61+
assert(a1 == a2);
6162
}
6263
}
6364
}

libcxx/test/std/containers/sequences/deque/deque.cons/move.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ int main(int, char**)
3838
assert(c2 == c3);
3939
assert(c1.size() == 0);
4040
assert(c3.get_allocator() == old_a);
41-
assert(c1.get_allocator() == A(test_alloc_base::moved_value));
41+
assert(c1.get_allocator() == A(1));
4242
LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c1));
4343
LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c2));
4444
LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c3));

libcxx/test/std/containers/sequences/vector.bool/move.pass.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,15 @@ TEST_CONSTEXPR_CXX20 bool tests()
8080
assert(alloc_stats.copied == 0);
8181
assert(alloc_stats.moved == 1);
8282
{
83-
const AllocT& a = v.get_allocator();
84-
assert(a.get_id() == test_alloc_base::moved_value);
85-
assert(a.get_data() == test_alloc_base::moved_value);
86-
}
87-
{
88-
const AllocT& a = v2.get_allocator();
89-
assert(a.get_id() == 101);
90-
assert(a.get_data() == 42);
83+
const AllocT& a1 = v.get_allocator();
84+
assert(a1.get_id() == test_alloc_base::moved_value);
85+
assert(a1.get_data() == 42);
86+
87+
const AllocT& a2 = v2.get_allocator();
88+
assert(a2.get_id() == 101);
89+
assert(a2.get_data() == 42);
90+
91+
assert(a1 == a2);
9192
}
9293
}
9394

libcxx/test/std/containers/sequences/vector/vector.cons/move.pass.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,15 @@ TEST_CONSTEXPR_CXX20 bool tests()
148148
assert(alloc_stats.copied == 0);
149149
assert(alloc_stats.moved == 1);
150150
{
151-
const test_allocator<int>& a = v.get_allocator();
152-
assert(a.get_id() == test_alloc_base::moved_value);
153-
assert(a.get_data() == test_alloc_base::moved_value);
154-
}
155-
{
156-
const test_allocator<int>& a = v2.get_allocator();
157-
assert(a.get_id() == 101);
158-
assert(a.get_data() == 42);
151+
const test_allocator<int>& a1 = v.get_allocator();
152+
assert(a1.get_id() == test_alloc_base::moved_value);
153+
assert(a1.get_data() == 42);
154+
155+
const test_allocator<int>& a2 = v2.get_allocator();
156+
assert(a2.get_id() == 101);
157+
assert(a2.get_data() == 42);
158+
159+
assert(a1 == a2);
159160
}
160161
}
161162

libcxx/test/support/test_allocator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ class test_allocator {
125125
}
126126
assert(a.data_ != test_alloc_base::destructed_value && a.id_ != test_alloc_base::destructed_value &&
127127
"moving from destroyed allocator");
128-
a.data_ = test_alloc_base::moved_value;
129128
a.id_ = test_alloc_base::moved_value;
130129
}
131130

0 commit comments

Comments
 (0)