I tried this code:
#[kani::requires(val < i32::MAX)]
#[kani::ensures(|result| *result == old(val + 1))]
pub fn next(mut val: i32) -> i32 {
val + 1
}
#[kani::proof_for_contract(next)]
pub fn check_next() {
// Placing the restriction before calling makes the problem go away.
// let _ = next(kani::any_where(|val: &i32| *val < i32::MAX));
let _ = next(kani::any());
}
using the following command line invocation:
kani -Z function-contracts next.rs
with Kani version:
I expected to see this happen: Verification succeeded
Instead, this happened: Verification failed due to overflow:
Failed Checks: attempt to add with overflow
File: "next.rs", line 2, in next_check_53aede
I tried this code:
using the following command line invocation:
with Kani version:
I expected to see this happen: Verification succeeded
Instead, this happened: Verification failed due to overflow: