[libcxx-commits] [libcxx] 8100aa4 - [libcxx] Use the unoptimized routines for volatile source types

via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jun 10 23:12:29 PDT 2023


Author: AdityaK
Date: 2023-06-10T23:11:47-07:00
New Revision: 8100aa4c02b04cd7d03b472f770d540f28cf5150

URL: https://github.com/llvm/llvm-project/commit/8100aa4c02b04cd7d03b472f770d540f28cf5150
DIFF: https://github.com/llvm/llvm-project/commit/8100aa4c02b04cd7d03b472f770d540f28cf5150.diff

LOG: [libcxx] Use the unoptimized routines for volatile source types

As reported in: D147741

Reviewers: philnik, var-const, ldionne, hans

Differential Revision: https://reviews.llvm.org/D152571

Added: 
    

Modified: 
    libcxx/include/__memory/uninitialized_algorithms.h
    libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__memory/uninitialized_algorithms.h b/libcxx/include/__memory/uninitialized_algorithms.h
index c02803330bcfb..2b68df8e6d634 100644
--- a/libcxx/include/__memory/uninitialized_algorithms.h
+++ b/libcxx/include/__memory/uninitialized_algorithms.h
@@ -573,7 +573,7 @@ template <class _Alloc,
           __enable_if_t<
               // using _RawTypeIn because of the allocator<T const> extension
               is_trivially_copy_constructible<_RawTypeIn>::value && is_trivially_copy_assignable<_RawTypeIn>::value &&
-              is_same<__remove_cv_t<_In>, __remove_cv_t<_Out> >::value &&
+              is_same<__remove_const_t<_In>, __remove_const_t<_Out> >::value &&
               __allocator_has_trivial_copy_construct<_Alloc, _RawTypeIn>::value>* = nullptr>
 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Out*
 __uninitialized_allocator_copy_impl(_Alloc&, _In* __first1, _In* __last1, _Out* __first2) {

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
index 810ea4f9fa44d..b0e626381454e 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
@@ -100,11 +100,20 @@ TEST_CONSTEXPR_CXX20 bool tests() {
     return true;
 }
 
+void test_copy_from_volatile_src() {
+    volatile int src[] = {1, 2, 3};
+    std::vector<int> v(src, src + 3);
+    assert(v[0] == 1);
+    assert(v[1] == 2);
+    assert(v[2] == 3);
+}
+
 int main(int, char**)
 {
     tests();
 #if TEST_STD_VER > 17
     static_assert(tests());
 #endif
+    test_copy_from_volatile_src();
     return 0;
 }


        


More information about the libcxx-commits mailing list