[libcxx-commits] [libcxx] [libc++] Add unsafe-buffer-usage attributes to span, vector, string and string_view (PR #119603)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jan 6 14:25:02 PST 2025
================
@@ -57,7 +58,10 @@ class __wrap_iter {
int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter(const __wrap_iter<_OtherIter>& __u) _NOEXCEPT
: __i_(__u.__i_) {}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT { return *__i_; }
+ _LIBCPP_VALID_ELEMENT_ACCESS_PRECONDITION _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference
----------------
geoffreygaren wrote:
The use case is when you've enabled hardening in libc++ (so you get bounds checking in span::operator[], array::operator[], etc.), but your vendor configuration -- e.g., Darwin user space -- does _not_ enable hardening for iterators (so you can't safely use span.begin(), array.begin(), etc.), because enabling hardening for iterators would break ABI.
https://github.com/llvm/llvm-project/pull/119603
More information about the libcxx-commits
mailing list