[libcxx-commits] [libcxx] [libcxx] adds additional checks to RAI containers' `erase` (PR #90919)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jun 10 05:43:10 PDT 2024


================
@@ -2398,7 +2400,12 @@ typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::erase(const_it
 
 template <class _Tp, class _Allocator>
 typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::erase(const_iterator __f, const_iterator __l) {
-  _LIBCPP_ASSERT_VALID_INPUT_RANGE(__f <= __l, "deque::erase(first, last) called with an invalid range");
+  _LIBCPP_ASSERT_VALID_INPUT_RANGE(
+    __f <= begin(), "deque::erase(first, last) called with an iterator range starting before 'begin()'");
----------------
ldionne wrote:

```suggestion
    __f >= begin(), "deque::erase(first, last) called with an iterator range starting before 'begin()'");
```

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


More information about the libcxx-commits mailing list