Skip to content

Kani fails to detect for loop bound after upgrade to nightly-2024-03-15 #3088

@celinval

Description

@celinval

While upgrading to nightly-2024-03-15, we had to add a few #[kani::unwind] attributes to harnesses with for loops with simple integer ranges. We need to investigate why this is no longer the case, and hopefully improve the loop bound detection algorithm.

Here is an example of a test case (tests/expected/iterator/main.rs):

#[kani::proof]
#[kani::unwind(4)] // Kani will unwind forever if we remove this attribute.
fn main() {
    let mut z = 1;
    for i in 1..4 {
        z *= i;
    }
    assert!(z == 6);
}

using the following command line invocation:

kani main.rs

with Kani version: #3084

I expected to see this happen: Kani should be able to automatically detect the loop bound.

Instead, this happened: Kani requires an unwind attribute.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-CBMCIssue related to an existing CBMC issue[C] BugThis is a bug. Something isn't working.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions