Skip to content

Incorrect std::find rule #456

Description

@joaotgouveia

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions