[libcxx] r274241 - Implement LWG#2596: 'vector::data() should use addressof'

Marshall Clow via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 30 08:50:55 PDT 2016


Author: marshall
Date: Thu Jun 30 10:50:55 2016
New Revision: 274241

URL: http://llvm.org/viewvc/llvm-project?rev=274241&view=rev
Log:
Implement LWG#2596: 'vector::data() should use addressof'

Modified:
    libcxx/trunk/test/std/containers/sequences/vector/vector.data/data.pass.cpp
    libcxx/trunk/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp
    libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/test/std/containers/sequences/vector/vector.data/data.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.data/data.pass.cpp?rev=274241&r1=274240&r2=274241&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.data/data.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.data/data.pass.cpp Thu Jun 30 10:50:55 2016
@@ -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<int> v(100);
-        assert(v.data() == &v.front());
+        assert(v.data() == std::addressof(v.front()));
+        assert(is_contiguous_container_asan_correct(v));
+    }
+    {
+        std::vector<Nasty> 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<int, min_allocator<int>> v(100);
-        assert(v.data() == &v.front());
+        assert(v.data() == std::addressof(v.front()));
+        assert(is_contiguous_container_asan_correct(v));
+    }
+    {
+        std::vector<Nasty, min_allocator<Nasty>> v(100);
+        assert(v.data() == std::addressof(v.front()));
         assert(is_contiguous_container_asan_correct(v));
     }
 #endif

Modified: libcxx/trunk/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp?rev=274241&r1=274240&r2=274241&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp Thu Jun 30 10:50:55 2016
@@ -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<int> v(100);
-        assert(v.data() == &v.front());
+        assert(v.data() == std::addressof(v.front()));
+        assert(is_contiguous_container_asan_correct(v));
+    }
+    {
+        std::vector<Nasty> 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<Nasty, min_allocator<Nasty>> v(100);
+        assert(v.data() == std::addressof(v.front()));
+        assert(is_contiguous_container_asan_correct(v));
+    }
 #endif
 }

Modified: libcxx/trunk/www/cxx1z_status.html
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=274241&r1=274240&r2=274241&view=diff
==============================================================================
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Thu Jun 30 10:50:55 2016
@@ -279,7 +279,7 @@
 	<tr><td><a href="http://wg21.link/LWG2551">2551</a></td><td>[fund.ts.v2] "Exception safety" cleanup in library fundamentals required</td><td>Oulu</td><td></td></tr>
 	<tr><td><a href="http://wg21.link/LWG2555">2555</a></td><td>[fund.ts.v2] No handling for over-aligned types in optional</td><td>Oulu</td><td></td></tr>
 	<tr><td><a href="http://wg21.link/LWG2573">2573</a></td><td>[fund.ts.v2] std::hash<std::experimental::shared_ptr> does not work for arrays</td><td>Oulu</td><td></td></tr>
-	<tr><td><a href="http://wg21.link/LWG2596">2596</a></td><td>vector::data() should use addressof</td><td>Oulu</td><td></td></tr>
+	<tr><td><a href="http://wg21.link/LWG2596">2596</a></td><td>vector::data() should use addressof</td><td>Oulu</td><td>Complete</td></tr>
 	<tr><td><a href="http://wg21.link/LWG2667">2667</a></td><td>path::root_directory() description is confusing</td><td>Oulu</td><td></td></tr>
 	<tr><td><a href="http://wg21.link/LWG2669">2669</a></td><td>recursive_directory_iterator effects refers to non-existent functions</td><td>Oulu</td><td></td></tr>
 	<tr><td><a href="http://wg21.link/LWG2670">2670</a></td><td>system_complete refers to undefined variable 'base'</td><td>Oulu</td><td></td></tr>




More information about the cfe-commits mailing list