Closed
Description
std::iter::Skip::count
currently calls count
on the inner iterator but that can overflow even if the Skip
itself doesn't return more that usize::max_value()
items.
For example:
(0..usize::max_value()).chain(0..10).skip(usize::max_value()).count()
This should return 10
but currently triggers an attempt to add with overflow
(or returns 0
if overflow checks are disabled).
This is caused by
rust/src/libcore/iter/adapters/mod.rs
Lines 1817 to 1820 in 1389494