Title
`concat_view::size` may overflow
Status
new
Section
[range.concat.view]
Submitter
Hewill Kang

Created on 2024-04-21.00:00:00 last changed 2 weeks ago

Messages

Date: 2024-04-21.00:00:00

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)
History
Date User Action Args
2024-04-21 00:00:00admincreate