diff options
| author | Eric Fiselier <eric@efcs.ca> | 2016-12-11 03:41:12 +0000 |
|---|---|---|
| committer | Eric Fiselier <eric@efcs.ca> | 2016-12-11 03:41:12 +0000 |
| commit | 1286bc577f70c5b8caa83b2440484fbbb3b15a6e (patch) | |
| tree | 98844f59716c7a4843315020a26019dfc474f054 /libcxx/test/std/containers/associative/map | |
| parent | b6398818780314c84e796ec1d4b1dbda27ddf554 (diff) | |
| download | bcm5719-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/associative/map')
| -rw-r--r-- | libcxx/test/std/containers/associative/map/map.special/non_member_swap.pass.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libcxx/test/std/containers/associative/map/map.special/non_member_swap.pass.cpp b/libcxx/test/std/containers/associative/map/map.special/non_member_swap.pass.cpp index 103a57b17e0..7e36797d092 100644 --- a/libcxx/test/std/containers/associative/map/map.special/non_member_swap.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.special/non_member_swap.pass.cpp @@ -121,17 +121,17 @@ int main() V(11, 11), V(12, 12) }; - M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1)); - M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2)); + M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1, 1)); + M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(1, 2)); M m1_save = m1; M m2_save = m2; swap(m1, m2); assert(m1 == m2_save); assert(m2 == m1_save); assert(m1.key_comp() == C(2)); - assert(m1.get_allocator() == A(1)); + assert(m1.get_allocator().get_id() == 1); // not swapped assert(m2.key_comp() == C(1)); - assert(m2.get_allocator() == A(2)); + assert(m2.get_allocator().get_id() == 2); } { typedef other_allocator<V> A; |

