[libcxx-commits] [libcxx] [libc++][hardening] Use bounded iterators in std::vector and std::string (PR #78929)
David Benjamin via libcxx-commits
libcxx-commits at lists.llvm.org
Mon May 20 12:28:53 PDT 2024
davidben wrote:
> NB: This PR depends on #78876. Ignore the first commit when reviewing, and don't merge it until #78876 is resolved. When/if #78876 lands, I'll clean this up.
This is now done. Two remaining open questions, other than generally needing review:
1. Should string iterators be bounded to size or capacity? https://github.com/llvm/llvm-project/pull/78929#issuecomment-1908305723
2. How to help the compiler optimize `std::vector`? https://github.com/llvm/llvm-project/pull/78929#issuecomment-1936582711.
For (1), I'm leaning towards leaving it as-is and seeing it it causes problems. If I'm reading the spec right, we're not obligated to keep that working.
For (2), I propose we land https://github.com/llvm/llvm-project/pull/91801 and then, in `vector::begin()` and `vector::end()`, add `_LIBCPP_ASSUME(size <= capacity)`. I believe that'll be enough for the compiler to optimize it, though I still need to confirm this.
@var-const, WDYT?
https://github.com/llvm/llvm-project/pull/78929
More information about the libcxx-commits
mailing list