<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61575>61575</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
std::exclusive_scan narrows to type of initial value
</td>
</tr>
<tr>
<th>Labels</th>
<td>
libc++
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
upsj
</td>
</tr>
</table>
<pre>
```
#include <vector>
#include <numeric>
#include <iostream>
#include <limits>
#include <cstdint>
int main() {
std::vector<std::int64_t> vec{1LL << 32, 0};
std::exclusive_scan(vec.begin(), vec.end(), vec.begin(), 0);
std::cout << vec[0] << '\n';
std::cout << vec[1] << '\n';
}
```
I would expect this to output 0 and 1LL<<32, but it outputs 0, 0, because T in std::exclusive_scan is deduced to `int`, which is the computational type that will be used in exclusive_scan. Not sure if this is a library or standard defect, but I think this is pretty bug-prone otherwise. Related to https://github.com/NVIDIA/thrust/issues/1896
https://godbolt.org/z/zMf5M9hGK
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VE2PIycQ_TX0pbQWTbu_Dn0Y23E0yuweoijXFQ1lNxsMLSjsnfz6iPZ4JrO7HgtDqz7eq1eFkDGao0McWL1h9a6QiSYfhjTHb8Xo9fPAGv6y-I7xByYq45RNGoFV2zMq8oFVv_3K6dIJg1F3vMZHCihPd9zWnAzFO04VSRtHb95lN47gJI1jomOiB9ZurnaIpFn1wKqHW7nbV4tx1Ky_ZiQ4o2Ltpnx6ygys2kIlmNgCZ-2OVT9B4XdlUzRn_BqVzJRnVKsRjzf6nJpN6PR7ww8xPJ8_wyuf6FZHLqzecFbvbhYmWlZvXT5eU19-HyCUHyNkndeP9xN_hItPVgN-n1ER0GQikAefaE4EHKTTUD49XYGvPRsTgaGXkJg1bq_biEqmiPAXGHevl2AiaNRJoc48rOF51M2Sf5mMmnIATQjKn-ZEkox30gI9zwg0SYKLsRZGhBRRZ5738Cv44gliCgjmcFVjIkiwZgwyPIMPEEk6LYMGjQdUdFP0mKPdP685c0CiZxjT8dMcvEPwNGG4mIgr-BOtpKuAiWiOWajYM7E_GprSuFL-xMT-y9-Pu8fsoCmkSEzsTYwJIxP7suub_1_uH1C8Hr2llQ9HJvb_5v_nQ_25n37_o9BDpfuqlwUOZdP2VdetO15MA-cHbLGtFXaHFrteds2aC5RVyRvd17Iwg-Ci4pUoeU7hq16Jqha8bFrsSlH1bM3xJI1dWXs-Ze5iKXdoyrqtCytHtHF5R4SwZlRMbJYl8rsShpz0aUzHyNbcmkjxDYYMWRzu3QcnQ_CX5dItQ_YHMM6QkRbO0iYsUrDDB13ONC9HHtS3ZaRvnV6q_y8AAP__z82Dxg">