| Issue |
169503
|
| Summary |
Compiler crash when passing `std::ranges::cbegin` to a function with `std::ranges::const_iterator_t` as a template parameter
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
redraincatching
|
Attempting to pass a `std::ranges::const_iterator_t` as a template parameter fails when `std::ranges::cbegin` is passed to the function.
```c++
#include <iterator>
#include <ranges>
#include <string>
template<std::input_iterator IT_T>
void some_function(IT_T)
{
}
int main(void) {
std::string someString;
some_function<std::ranges::const_iterator_t<std::string>>(std::ranges::cbegin(someString));
}
```
causes the compiler to fail with the following output:
```
<source>:13:4: error: no matching function for call to 'some_function'
13 | some_function<std::ranges::const_iterator_t<std::string>>(std::ranges::cbegin(someString));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:6:6: note: candidate function template not viable: no known conversion from 'const_iterator_t<decltype(__r)>' to 'const_iterator_t<std::string>' for 1st argument
6 | void some_function(IT_T)
| ^ ~~~~
1 error generated.
Compiler returned: 1
```
note that adding const to the variable and the `const_iterator_t` type results in the program compiling as expected
```c++
#include <iterator>
#include <ranges>
#include <string>
template<std::input_iterator IT_T>
void some_function(IT_T)
{
}
int main(void) {
std::string const someString;
some_function<std::ranges::const_iterator_t<std::string const&>>(std::ranges::cbegin(someString));
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs