[libcxx-commits] [libcxx] [libc++] Add unsafe-buffer-usage attributes to span, vector, string and string_view (PR #119603)

Dana Jansens via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jan 9 09:02:54 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
----------------
danakj wrote:

Shouldn't this generate -Wunsafe-buffer-usage even if hardening is not enabled then too? The warning isn't tied to hardening. These iterators are never safe buffer usage.

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


More information about the libcxx-commits mailing list