[libcxx-commits] [libcxx] Non-constant instances have been made constant in data_const.pass.cpp (PR #122085)

via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jan 8 02:14:23 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: LoS (2LoS)

<details>
<summary>Changes</summary>

Non-constant instances have been made constant in **data_const.pass.cpp** tests, which verify the correct working of the `data()` member function for constant instances of the `std::vector` container (libc++).

---
Full diff: https://github.com/llvm/llvm-project/pull/122085.diff


1 Files Affected:

- (modified) libcxx/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp (+11-11) 


``````````diff
diff --git a/libcxx/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp
index 885caf272afbf2..05afe0160032ac 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp
@@ -39,7 +39,7 @@ TEST_CONSTEXPR_CXX20 bool tests()
         assert(is_contiguous_container_asan_correct(v));
     }
     {
-        std::vector<Nasty> v(100);
+        const std::vector<Nasty> v(100);
         assert(v.data() == std::addressof(v.front()));
         assert(is_contiguous_container_asan_correct(v));
     }
@@ -55,24 +55,24 @@ TEST_CONSTEXPR_CXX20 bool tests()
         assert(is_contiguous_container_asan_correct(v));
     }
     {
-        std::vector<Nasty, min_allocator<Nasty>> v(100);
+        const std::vector<Nasty, min_allocator<Nasty>> v(100);
         assert(v.data() == std::addressof(v.front()));
         assert(is_contiguous_container_asan_correct(v));
     }
     {
-      const std::vector<int, safe_allocator<int>> v;
-      assert(v.data() == 0);
-      assert(is_contiguous_container_asan_correct(v));
+        const std::vector<int, safe_allocator<int>> v;
+        assert(v.data() == 0);
+        assert(is_contiguous_container_asan_correct(v));
     }
     {
-      const std::vector<int, safe_allocator<int>> v(100);
-      assert(v.data() == &v.front());
-      assert(is_contiguous_container_asan_correct(v));
+        const std::vector<int, safe_allocator<int>> v(100);
+        assert(v.data() == &v.front());
+        assert(is_contiguous_container_asan_correct(v));
     }
     {
-      std::vector<Nasty, safe_allocator<Nasty>> v(100);
-      assert(v.data() == std::addressof(v.front()));
-      assert(is_contiguous_container_asan_correct(v));
+        const std::vector<Nasty, safe_allocator<Nasty>> v(100);
+        assert(v.data() == std::addressof(v.front()));
+        assert(is_contiguous_container_asan_correct(v));
     }
 #endif
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/122085


More information about the libcxx-commits mailing list