The std::find rule is written as follows:
fn f3<T1: PartialEq + Clone + ByteRepr>(a0: Ptr<T1>, a1: Ptr<T1>, a2: T1) -> Ptr<T1> {
a0.offset(a0.clone().into_iter().enumerate()
.position(|(index_0, value_0)| index_0 < a1.get_offset() as usize && value_0.read() == a2)
.unwrap_or(a1.get_offset() as usize) as isize)
}
The issue here is that enumerate is relative, but a1.get_offset() returns an absolute position. If a0 does not start at offset 0, the first index_0 yielded by a0.clone().into_iter().enumerate() will still be 0. As such, if a0 does not start at offset 0, the bound index_0 < a1.get_offset() overshoots.
The
std::findrule is written as follows:The issue here is that
enumerateis relative, buta1.get_offset()returns an absolute position. Ifa0does not start at offset 0, the firstindex_0yielded bya0.clone().into_iter().enumerate()will still be 0. As such, ifa0does not start at offset 0, the boundindex_0 < a1.get_offset()overshoots.