Closed
Description
I tried this code:
#[requires(assert_valid_ptr(dst) && has_valid_value(dst))]
#[modifies(dst)]
pub unsafe fn replace<T>(dst: *mut T, src: T) -> T {
std::ptr::replace(dst, src)
}
/// This one fails in the builtin-library
#[kani::proof_for_contract(contracts::replace)]
pub fn check_replace_unit() {
check_replace_impl::<()>();
}
/// This one succeeds
#[kani::proof_for_contract(contracts::replace)]
pub fn check_replace_char() {
check_replace_impl::<char>();
}
fn check_replace_impl<T: kani::Arbitrary + Eq + Clone>() {
let mut dst = T::any();
let orig = dst.clone();
let src = T::any();
let ret = unsafe { contracts::replace(&mut dst, src.clone()) };
assert_eq!(ret, orig);
assert_eq!(dst, src);
}
using the following command line invocation:
kani contracts.rs
with Kani version: 0.51.0-dev (#3107)
I expected to see this happen: verification succeeds
Instead, this happened: Verification failed with the following failure:
SUMMARY:
** 1 of 1485 failed (3 unreachable)
Failed Checks: ptr NULL or writable up to size
File: "<builtin-library-__CPROVER_contracts_library>", line 162, in __CPROVER_contracts_car_set_insert