[libcxx-commits] [libcxx] [libc++] Add some _LIBCPP_ASSUMEs for bounded iterators (PR #109033)

David Benjamin via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 17 12:30:39 PDT 2024


================
@@ -850,6 +850,10 @@ private:
 
   _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator __make_iter(pointer __p) _NOEXCEPT {
 #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
+    // `__bounded_iter` will tell the compiler that `__p` is bounded by `__begin_` and `__end_cap`, but nothing a priori
+    // relates `__p` to `__end_`.
+    _LIBCPP_ASSUME(__p <= this->__end_);
----------------
davidben wrote:

Not sure if this is strictly needed. I did this for the `__make_iter` calls that don't pass one of `begin` or `end`. Thoughts?

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


More information about the libcxx-commits mailing list