Unexpected possible index out of bounds warning in direct vector iteration
darioncassel opened this issue · comments
Issue
The following test case produces several error messages that center around a possible index out of bounds and analysis fixed point loop iterations exceeding their limit.
Steps to Reproduce
Test case that produces the wrong output:
pub fn test() {
let mut bar: Vec<Foo> = vec!();
bar.push(Foo { content: 0 });
for i in 0..bar.len() {
assume!(i < bar.len()); //~assumption is provably true and can be deleted
add_tag!(&bar[i], SecretTaint); //~possible index out of bounds
println!("{}", bar[i].content);
}
//~Fixed point loop iterations exceeded limit of 10
}
Expected Behavior
The loop body contains vector indexing using the loop induction variable, which is bounded by the length of the vector; it is in-bounds. There should be no error messages raised by MIRAI.
Actual Results
Several error messages are raised:
- MIRAI claims that the vector indexing is a case of
possible index out of bounds
. Yet, if an assumption is added to show that the induction variable does indeed fall within the vector bounds MIRAI notes that thisassumption is provably true and can be deleted
. - MIRAI raises the error
Fixed point loop iterations exceeded limit of 10
.
Environment
rustc 1.55.0-nightly (7c3872e6b 2021-06-24)