[libcxx-commits] [libcxx] [libc++] Add support for bounded iterators in std::array (PR #110729)

Adrian Vogelsgesang via libcxx-commits libcxx-commits at lists.llvm.org
Wed Oct 2 06:08:06 PDT 2024


================
@@ -176,6 +176,12 @@
 // ABI impact: changes the iterator type of `vector` (except `vector<bool>`).
 // #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
 
+// Changes the iterator type of `array` to a bounded iterator that keeps track of whether it's within the bounds of the
+// container and asserts it on every dereference and when performing iterator arithmetic.
+//
+// ABI impact: changes the iterator type of `array`.
+// #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY
----------------
vogelsgesang wrote:

> We have to store the beginning of the array in addition to the pointer into the array itself.

Ah, I wasn't aware of that (only read the commit message, not the code)

> My preference would be to be consistent with other similar ABI settings for hardening and not enable them by default in ABI v2.

makes sense

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


More information about the libcxx-commits mailing list