[libcxx-commits] [libcxx] [libc++][hardening] Check bounds on arithmetic in __bounded_iter (PR #78876)
Konstantin Varlamov via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Feb 14 00:06:36 PST 2024
================
@@ -91,21 +90,25 @@ struct __bounded_iter {
// Dereference and indexing operations.
//
// These operations check that the iterator is dereferenceable, that is within [begin, end).
----------------
var-const wrote:
How about
```
These operations check that the iterator is dereferenceable. Since the class invariant is that the
iterator is always within `[begin, end]`, we only need to check it's not pointing to `end`. This
happens to be more friendly for the optimizer (see <link>).
```
(I mainly want to get rid of two repetitions of `begin, end` in a row, one including and one not including the end -- IMO that reads a little disjointed)
https://github.com/llvm/llvm-project/pull/78876
More information about the libcxx-commits
mailing list