[libcxx-commits] [PATCH] D152571: Use the unoptimized routines for volatile source types
Aditya Kumar via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jun 9 14:22:34 PDT 2023
hiraditya updated this revision to Diff 530082.
hiraditya added a comment.
Added testcase.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152571/new/
https://reviews.llvm.org/D152571
Files:
libcxx/include/__memory/uninitialized_algorithms.h
libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
Index: libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
===================================================================
--- libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
+++ libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
@@ -100,11 +100,25 @@
return true;
}
+std::vector<int> copy_from_volatile_src(volatile int *p, int n) {
+ std::vector<int> v(p, p + n);
+ return v;
+}
+
+void test_copy_from_volatile_src() {
+ int src[] = {1, 2, 3};
+ auto v = copy_from_volatile_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;
}
Index: libcxx/include/__memory/uninitialized_algorithms.h
===================================================================
--- libcxx/include/__memory/uninitialized_algorithms.h
+++ libcxx/include/__memory/uninitialized_algorithms.h
@@ -573,7 +573,7 @@
__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) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152571.530082.patch
Type: text/x-patch
Size: 1686 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230609/f5207e99/attachment.bin>
More information about the libcxx-commits
mailing list