<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/67551>67551</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[libc++] [ranges] sized_range of iota_view<short, short>
</td>
</tr>
<tr>
<th>Labels</th>
<td>
libc++
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jonathan-hopkins
</td>
</tr>
</table>
<pre>
Hi. The following code, when compiled with libc++, is unable to deduce the correct size type of iota_view. Changing short to a different integral type generates no errors.
```
#include <ranges>
#include <numeric>
int main() {
static_assert(std::ranges::sized_range<std::ranges::iota_view<short, short>>, "short");
}
```
clang output:
```
In file included from <source>:1:
In file included from /opt/compiler-explorer/clang-16.0.0/bin/../include/c++/v1/ranges:353:
In file included from /opt/compiler-explorer/clang-16.0.0/bin/../include/c++/v1/__ranges/drop_view.h:30:
/opt/compiler-explorer/clang-16.0.0/bin/../include/c++/v1/__ranges/iota_view.h:368:9: error: 'auto' in return type deduced as 'int' here but deduced as '__make_unsigned_t<int>' (aka 'unsigned int') in earlier return statement
return std::__to_unsigned_like(__bound_sentinel_) - std::__to_unsigned_like(__value_);
^
/opt/compiler-explorer/clang-16.0.0/bin/../include/c++/v1/__ranges/size.h:55:29: note: in instantiation of member function 'std::ranges::iota_view<short, short>::size' requested here
{ _LIBCPP_AUTO_CAST(__t.size()) } -> __integer_like;
^
/opt/compiler-explorer/clang-16.0.0/bin/../include/c++/v1/__ranges/size.h:55:7: note: in instantiation of requirement here
{ _LIBCPP_AUTO_CAST(__t.size()) } -> __integer_like;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/clang-16.0.0/bin/../include/c++/v1/__utility/auto_cast.h:20:33: note: expanded from macro '_LIBCPP_AUTO_CAST'
#define _LIBCPP_AUTO_CAST(expr) static_cast<typename decay<decltype((expr))>::type>(expr)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/clang-16.0.0/bin/../include/c++/v1/__ranges/size.h:54:3: note: while substituting template arguments into constraint expression here
requires(_Tp&& __t) {
^~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/clang-16.0.0/bin/../include/c++/v1/__ranges/size.h:92:13: note: while checking the satisfaction of concept '__member_size<std::ranges::iota_view<short, short> &>' requested here
template <__member_size _Tp>
^
/opt/compiler-explorer/clang-16.0.0/bin/../include/c++/v1/__ranges/size.h:92:13: note: while substituting template arguments into constraint expression here
template <__member_size _Tp>
^~~~~~~~~~~~~
/opt/compiler-explorer/clang-16.0.0/bin/../include/c++/v1/__ranges/concepts.h:78:60: note: while checking constraint satisfaction for template 'operator()<std::ranges::iota_view<short, short> &>' required here
concept sized_range = range<_Tp> && requires(_Tp& __t) { ranges::size(__t); };
^~~~~~
/opt/compiler-explorer/clang-16.0.0/bin/../include/c++/v1/__ranges/concepts.h:78:60: note: in instantiation of function template specialization 'std::ranges::__size::__fn::operator()<std::ranges::iota_view<short, short> &>' requested here
/opt/compiler-explorer/clang-16.0.0/bin/../include/c++/v1/__ranges/concepts.h:78:60: note: in instantiation of requirement here
concept sized_range = range<_Tp> && requires(_Tp& __t) { ranges::size(__t); };
^~~~~~~~~~~~~~~~~
/opt/compiler-explorer/clang-16.0.0/bin/../include/c++/v1/__ranges/concepts.h:78:39: note: while substituting template arguments into constraint expression here
concept sized_range = range<_Tp> && requires(_Tp& __t) { ranges::size(__t); };
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:5:19: note: while checking the satisfaction of concept 'sized_range<std::ranges::iota_view<short, short>>' requested here
static_assert(std::ranges::sized_range<std::ranges::iota_view<short, short>>, "short");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Compiler returned: 1
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJz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