[BUG]: `thrust::zip_iterator` allows out-of-bounds access if first iterator is longer than the others
- Dominant language
- C++
- Stars
- 2.5k
- Forks
- 487
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 296
Description
### Is this a duplicate?
- [X] I confirmed there appear to be no [duplicate issues](https://github.com/NVIDIA/cccl/issues) for this bug and that I agree to the [Code of Conduct](CODE_OF_CONDUCT.md)
### Type of Bug
Runtime Error
### Component
Thrust
### Describe the bug
Out of bounds access when the first iterator in a `zip_iterator` is longer than the others
### How to Reproduce
```c++
// clang++ -I/path/to/thrust thrust_bug.cpp -o thrust_bug && ./thrust_bug
#include
#include
#include
#include
int main()
{
std::vector v(4, 0); // change me to 5!
std::vector y(4, 1);
auto zip_begin = thrust::make_zip_iterator(thrust::make_tuple(v.begin(), y.begin()));
auto zip_end = thrust::make_zip_iterator(thrust::make_tuple(v.end(), y.end()));
for (auto it = zip_begin; it != zip_end; ++it) {
// BOOM out of bounds
std::cout << "[" << thrust::get<0>(*it) << ", " << thrust::get<1>(*it) << "]" << std::endl;
}
}
```
Note the size of `v` and `y` are equal. If, however, you change `v` to be size 5
```diff
- std::vector v(4, 0);
+ std::vector v(5, 0);
```
You will find that the iterator runs out of bounds.
### Expected behavior
No out of bounds
### Reproduction link
_No response_
### Operating System
_No response_
### nvidia-smi output
_No response_
### NVCC version
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.