BillyONeal created this revision. BillyONeal added reviewers: mclow.lists, EricWF, ldionne. Herald added a subscriber: dexonsmith.
The standard only requires that moved-from standard library types are in a 'valid but unspecified state', not that any moved-from container is empty. When the container is using a POCMA allocator, asserting that the moved-from container is empty is reasonable because the target container needs to take ownership of the memory buffers allocated from the source container's allocator. However, when the allocator is non-POCMA, the destination container must not take over any buffers, and effectively must copy the contents of the source container. In the MSVC++ implementation, in this non-POCMA case, we do not clear() the source container, so that subsequent operations can reuse memory if the container is not immediately destroyed. https://reviews.llvm.org/D61366 Files: test/std/containers/associative/map/map.cons/move_assign.pass.cpp test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp test/std/containers/associative/set/set.cons/move_assign.pass.cpp Index: test/std/containers/associative/set/set.cons/move_assign.pass.cpp =================================================================== --- test/std/containers/associative/set/set.cons/move_assign.pass.cpp +++ test/std/containers/associative/set/set.cons/move_assign.pass.cpp @@ -100,7 +100,7 @@ assert(m3 == m2); assert(m3.get_allocator() == A(5)); assert(m3.key_comp() == C(5)); - assert(m1.empty()); + LIBCPP_ASSERT(m1.empty()); } { typedef MoveOnly V; Index: test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp =================================================================== --- test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp +++ test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp @@ -100,7 +100,7 @@ assert(m3 == m2); assert(m3.get_allocator() == A(5)); assert(m3.key_comp() == C(5)); - assert(m1.empty()); + LIBCPP_ASSERT(m1.empty()); } { typedef MoveOnly V; Index: test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp =================================================================== --- test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp +++ test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp @@ -102,7 +102,7 @@ assert(m3 == m2); assert(m3.get_allocator() == A(5)); assert(m3.key_comp() == C(5)); - assert(m1.empty()); + LIBCPP_ASSERT(m1.empty()); } { typedef std::pair<MoveOnly, MoveOnly> V; Index: test/std/containers/associative/map/map.cons/move_assign.pass.cpp =================================================================== --- test/std/containers/associative/map/map.cons/move_assign.pass.cpp +++ test/std/containers/associative/map/map.cons/move_assign.pass.cpp @@ -102,7 +102,7 @@ assert(m3 == m2); assert(m3.get_allocator() == A(5)); assert(m3.key_comp() == C(5)); - assert(m1.empty()); + LIBCPP_ASSERT(m1.empty()); } { typedef std::pair<MoveOnly, MoveOnly> V;
Index: test/std/containers/associative/set/set.cons/move_assign.pass.cpp =================================================================== --- test/std/containers/associative/set/set.cons/move_assign.pass.cpp +++ test/std/containers/associative/set/set.cons/move_assign.pass.cpp @@ -100,7 +100,7 @@ assert(m3 == m2); assert(m3.get_allocator() == A(5)); assert(m3.key_comp() == C(5)); - assert(m1.empty()); + LIBCPP_ASSERT(m1.empty()); } { typedef MoveOnly V; Index: test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp =================================================================== --- test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp +++ test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp @@ -100,7 +100,7 @@ assert(m3 == m2); assert(m3.get_allocator() == A(5)); assert(m3.key_comp() == C(5)); - assert(m1.empty()); + LIBCPP_ASSERT(m1.empty()); } { typedef MoveOnly V; Index: test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp =================================================================== --- test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp +++ test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp @@ -102,7 +102,7 @@ assert(m3 == m2); assert(m3.get_allocator() == A(5)); assert(m3.key_comp() == C(5)); - assert(m1.empty()); + LIBCPP_ASSERT(m1.empty()); } { typedef std::pair<MoveOnly, MoveOnly> V; Index: test/std/containers/associative/map/map.cons/move_assign.pass.cpp =================================================================== --- test/std/containers/associative/map/map.cons/move_assign.pass.cpp +++ test/std/containers/associative/map/map.cons/move_assign.pass.cpp @@ -102,7 +102,7 @@ assert(m3 == m2); assert(m3.get_allocator() == A(5)); assert(m3.key_comp() == C(5)); - assert(m1.empty()); + LIBCPP_ASSERT(m1.empty()); } { typedef std::pair<MoveOnly, MoveOnly> V;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits