summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/containers/sequences/deque/deque.special/swap.pass.cpp
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-12-11 03:41:12 +0000
committerEric Fiselier <eric@efcs.ca>2016-12-11 03:41:12 +0000
commit1286bc577f70c5b8caa83b2440484fbbb3b15a6e (patch)
tree98844f59716c7a4843315020a26019dfc474f054 /libcxx/test/std/containers/sequences/deque/deque.special/swap.pass.cpp
parentb6398818780314c84e796ec1d4b1dbda27ddf554 (diff)
downloadbcm5719-llvm-1286bc577f70c5b8caa83b2440484fbbb3b15a6e.tar.gz
bcm5719-llvm-1286bc577f70c5b8caa83b2440484fbbb3b15a6e.zip
Fix undefined behavior in container swap tests.
These swap tests were swapping non-POCS non-equal allocators which is undefined behavior. This patch changes the tests to use allocators which compare equal. In order to test that the allocators were not swapped I added an "id" field to test_allocator which does not participate in equality but does propagate across copies/swaps. This patch is based off of D26623 which was submitted by STL. llvm-svn: 289358
Diffstat (limited to 'libcxx/test/std/containers/sequences/deque/deque.special/swap.pass.cpp')
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.special/swap.pass.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/libcxx/test/std/containers/sequences/deque/deque.special/swap.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.special/swap.pass.cpp
index ab21f434937..05bbf878ae0 100644
--- a/libcxx/test/std/containers/sequences/deque/deque.special/swap.pass.cpp
+++ b/libcxx/test/std/containers/sequences/deque/deque.special/swap.pass.cpp
@@ -65,13 +65,13 @@ int main()
int a1[] = {1, 3, 7, 9, 10};
int a2[] = {0, 2, 4, 5, 6, 8, 11};
typedef test_allocator<int> A;
- std::deque<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
- std::deque<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+ std::deque<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1, 1));
+ std::deque<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(1, 2));
swap(c1, c2);
assert((c1 == std::deque<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
- assert(c1.get_allocator() == A(1));
+ assert(c1.get_allocator().get_id() == 1);
assert((c2 == std::deque<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
- assert(c2.get_allocator() == A(2));
+ assert(c2.get_allocator().get_id() == 2);
}
{
int a1[] = {1, 3, 7, 9, 10};
OpenPOWER on IntegriCloud