You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Loop contracts: a write missing from loop_modifies is accepted at -Zmir-opt-level=2 (the kani_loop_modifies binding is optimized out) #5053
with Kani version: main (reproduces at -Zmir-opt-level 2 and above)
I expected to see this happen: verification fails. hidden is written inside the loop but is not in #[kani::loop_modifies(&i)], so the write is outside the declared modifies set. At -Zmir-opt-level=1 this is what happens: the harness fails Check that hidden is assignable.
Instead, this happened: at -Zmir-opt-level=2 and above, the harness reports VERIFICATION SUCCESSFUL. The write to hidden, absent from loop_modifies, is silently admitted.
Likely cause: nothing reads the kani_loop_modifies binding, so MIR optimizations at level 2 and above remove it. With the binding gone, CBMC infers the write set from the loop body instead of enforcing the declared clause. The #[inline(never)] keep-alive that #4946 added for the loop_decreases measure binding fixes it in a local test; the same keep-alive on the loop_modifies binding should force it to survive optimization.
Activity