From f0419f1dccf299884645f11cf0bc27f233fae326 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Thu, 30 Jun 2016 15:50:55 +0000 Subject: [PATCH] Implement LWG#2596: 'vector::data() should use addressof' git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@274241 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../vector/vector.data/data.pass.cpp | 23 +++++++++++++++++-- .../vector/vector.data/data_const.pass.cpp | 21 ++++++++++++++++- www/cxx1z_status.html | 2 +- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/test/std/containers/sequences/vector/vector.data/data.pass.cpp b/test/std/containers/sequences/vector/vector.data/data.pass.cpp index 0b58601c4..f6c0575d9 100644 --- a/test/std/containers/sequences/vector/vector.data/data.pass.cpp +++ b/test/std/containers/sequences/vector/vector.data/data.pass.cpp @@ -17,6 +17,15 @@ #include "min_allocator.h" #include "asan_testing.h" +struct Nasty { + Nasty() : i_(0) {} + Nasty(int i) : i_(i) {} + ~Nasty() {} + + Nasty * operator&() const { assert(false); return nullptr; } + int i_; + }; + int main() { { @@ -26,7 +35,12 @@ int main() } { std::vector v(100); - assert(v.data() == &v.front()); + assert(v.data() == std::addressof(v.front())); + assert(is_contiguous_container_asan_correct(v)); + } + { + std::vector v(100); + assert(v.data() == std::addressof(v.front())); assert(is_contiguous_container_asan_correct(v)); } #if TEST_STD_VER >= 11 @@ -37,7 +51,12 @@ int main() } { std::vector> v(100); - assert(v.data() == &v.front()); + assert(v.data() == std::addressof(v.front())); + assert(is_contiguous_container_asan_correct(v)); + } + { + std::vector> v(100); + assert(v.data() == std::addressof(v.front())); assert(is_contiguous_container_asan_correct(v)); } #endif diff --git a/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp b/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp index ac6ecd1e4..c97ad2970 100644 --- a/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp +++ b/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp @@ -17,6 +17,15 @@ #include "min_allocator.h" #include "asan_testing.h" +struct Nasty { + Nasty() : i_(0) {} + Nasty(int i) : i_(i) {} + ~Nasty() {} + + Nasty * operator&() const { assert(false); return nullptr; } + int i_; + }; + int main() { { @@ -26,7 +35,12 @@ int main() } { const std::vector v(100); - assert(v.data() == &v.front()); + assert(v.data() == std::addressof(v.front())); + assert(is_contiguous_container_asan_correct(v)); + } + { + std::vector v(100); + assert(v.data() == std::addressof(v.front())); assert(is_contiguous_container_asan_correct(v)); } #if TEST_STD_VER >= 11 @@ -40,5 +54,10 @@ int main() assert(v.data() == &v.front()); assert(is_contiguous_container_asan_correct(v)); } + { + std::vector> v(100); + assert(v.data() == std::addressof(v.front())); + assert(is_contiguous_container_asan_correct(v)); + } #endif } diff --git a/www/cxx1z_status.html b/www/cxx1z_status.html index c121e1465..35f237d03 100644 --- a/www/cxx1z_status.html +++ b/www/cxx1z_status.html @@ -279,7 +279,7 @@ 2551[fund.ts.v2] "Exception safety" cleanup in library fundamentals requiredOulu 2555[fund.ts.v2] No handling for over-aligned types in optionalOulu 2573[fund.ts.v2] std::hash<std::experimental::shared_ptr> does not work for arraysOulu - 2596vector::data() should use addressofOulu + 2596vector::data() should use addressofOuluComplete 2667path::root_directory() description is confusingOulu 2669recursive_directory_iterator effects refers to non-existent functionsOulu 2670system_complete refers to undefined variable 'base'Oulu