[libcxx-commits] [libcxx] [libc++] Harden the algorithms against volatile pointers (PR #222813)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Sep 15 07:46:46 PDT 2026
================
@@ -59,11 +61,15 @@ __assume_valid_range([[__maybe_unused__]] _Iter&& __first, [[__maybe_unused__]]
is_same<__remove_cvref_t<_Iter>, __remove_cvref_t<_Sent>>::value) {
_LIBCPP_ASSERT_INTERNAL(std::__is_valid_range(std::__to_address(__first), std::__to_address(__last)),
"Valid range assumption does not hold");
- if (!__libcpp_is_constant_evaluated()) {
- using __value_type = typename iterator_traits<__remove_cvref_t<_Iter>>::value_type;
- __builtin_assume_dereferenceable(std::__to_address(__first), (__last - __first) * sizeof(__value_type));
- (void)std::__assume_aligned<_LIBCPP_ALIGNOF(__value_type)>(std::__to_address(__first));
- (void)std::__assume_aligned<_LIBCPP_ALIGNOF(__value_type)>(std::__to_address(__last));
+ // We can't make these assumptions for volatile pointers since the builtins take a plain pointer.
----------------
ldionne wrote:
Let me know if what I did matches what you had in mind!
https://github.com/llvm/llvm-project/pull/222813
More information about the libcxx-commits
mailing list