diff options
author | Hui <hui.xie1990@gmail.com> | 2024-10-19 11:09:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-19 11:09:25 +0100 |
commit | 1bbf3a37056761ec407031431e28f856428566f0 (patch) | |
tree | 5147126b1ea44bb75acc673cd044da05072e52d2 /llvm/tools/llvm-cov/SourceCoverageViewText.cpp | |
parent | aa320600e2b7136f5156dd0c31f98ec0f8d5bce1 (diff) | |
download | llvm-1bbf3a37056761ec407031431e28f856428566f0.zip llvm-1bbf3a37056761ec407031431e28f856428566f0.tar.gz llvm-1bbf3a37056761ec407031431e28f856428566f0.tar.bz2 |
[libc++] Fix `reverse_iterator` when underlying is c++20 `bidirectional_iterator` but not `Cpp17BidirectionalIterator` (#112100)
`reverse_iterator` supports either c++20 `bidirectional_iterator` or
`Cpp17BidirectionalIterator `
http://eel.is/c++draft/reverse.iter.requirements
The current `reverse_iterator` uses `std::prev` in its `operator->`,
which only supports the `Cpp17BidirectionalIterator` properly.
If the underlying iterator is c++20 `bidirectional_iterator` but does
not satisfy the named requirement `Cpp17BidirectionalIterator`,
(examples are `zip_view::iterator`, `flat_map::iterator`), the current
`std::prev` silently compiles but does a no-op and returns the same
iterator back. So `reverse_iterator::operator->` will silently give a
wrong answer.
Even if we fix the behaviour of `std::prev`, at best, we could fail to
compile the code. But this is not ok, because we need to support this
kind of iterators in `reverse_iterator`.
The solution is simply to not use `std::prev`.
---------
Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
Diffstat (limited to 'llvm/tools/llvm-cov/SourceCoverageViewText.cpp')
0 files changed, 0 insertions, 0 deletions