[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
Mon Jan 6 11:02:10 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:

This warns when hardening is disabled, but whether the checking is happening is dependent also on the checked iterator ABI flag. In this case, since the checked iterator ABI flag is off (we're using `__wrap_iter`) the hardening flag has no effect, so it the behaviour would always be what I would expect to be flagged as unsafe_buffer_usage, even if hardening is enabled? Or am I misunderstanding when __wrap_iter is used?

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


More information about the libcxx-commits mailing list