`thrust::exclusive_scan` deduces value type from identity value
- Dominant language
- C++
- Stars
- 2.5k
- Forks
- 487
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 296
Description
I ran into a particularly hard-to-spot issue that I would consider a bug ~~in Thrust~~ in the C++ standard 😄 :
```cpp
#include
#include
#include
#include
#include
int main() {
thrust::device_vector vec(3);
vec[0] = std::numeric_limits::max() - 1;
vec[1] = 1;
vec[2] = 0;
thrust::exclusive_scan(vec.begin(), vec.end(), vec.begin(), 0);
std::cout << vec[0] << '\n';
std::cout << vec[1] << '\n';
std::cout << vec[2] << '\n';
}
```
I would expect this to output 0, LONG_MAX - 1 and LONG_MAX, instead it outputs 0, -2, -1.
EDIT: I checked with std::exclusive_scan, and I get the same behavior, but TBH this seems like a really bug-prone specification to me. I would expect the computational type to be derived based on the return type of the associative operation or the iterator types.
Contributor guide
Assessment
This issue has not been assessed yet.