viperproject / prusti-dev

A static verifier for Rust, based on the Viper verification infrastructure.
http://prusti.org
Other
1.58k stars 108 forks source link

Inconsistency in the encoding of Rust addresses as Viper Ref types #1506

Open fpoli opened 8 months ago

fpoli commented 8 months ago

An example to be fixed in the the ongoing Prusti rewrite:

use prusti_contracts::*;

#[requires(*x == a && a != b)]
//#[after_expiry(*x == before_expiry(*result))] // Does not verify, but it should
#[after_expiry(*x == a)] // Verifies, but it shouldn't
pub fn foo<T: Eq + Copy>(x: &mut T, a: T, b: T) -> &mut T {
    *x = b;
    x
}

#[requires(*x == a && a != b)]
pub fn bug(x: &mut u32, a: u32, b: u32) {
    let _ = foo(x, a, b);
    assert!(*x == a); // Verifies, but fails at runtime
}