concat_view::size
may overflowSection: 25.7.18.2 [range.concat.view] Status: New Submitter: Hewill Kang Opened: 2024-04-21 Last modified: 2024-06-24
Priority: 4
View other active issues in [range.concat.view].
View all other issues in [range.concat.view].
View all issues with New status.
Discussion:
Currently, concat_view::size
returns the sum of sizes of all underlying ranges,
and the return type is specified to be the common type of all sizes, which may lead to
potential overflow:
auto r = std::views::iota(0uz, SIZE_MAX);
std::print("{}\n", r.size()); // 18446744073709551615 (size_t)
std::print("{}\n", r.end() - r.begin()); // 18446744073709551615 (__int128)
auto c = std::views::concat(r, r);
std::print("{}\n", c.size()); // 18446744073709551614 (size_t)
std::print("{}\n", c.end() - c.begin()); // 36893488147419103230 (__int128)
[2024-06-24; Reflector poll]
Set priority to 4 after reflector poll.
Same behaviour as join_view
, was there some discussion of this being
covered by general wording?
Proposed resolution: