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
pubfntest() -> [u8;4]{letmut b = [1,2,3,4];
b.reverse();
b
}
The problem is that the default signature we generate for reverse is fn(&mut ∃v. [T][v]) which cannot guarantee the length of the slice doesn't change (the length of a slice cannot change but the type can't guarantee it). Since we are casting &mut [T; n] to &mut [T][n] the call to reverse fails because &mut [T][n] is not a subtype of &mut ∃v. [T][v].
The text was updated successfully, but these errors were encountered:
ranjitjhala
changed the title
False negative with usize cast from &mut [T; n] to &mut [T]
False positive with usize cast from &mut [T; n] to &mut [T]Aug 17, 2024
The following code fails to verify
The problem is that the default signature we generate for
reverse
isfn(&mut ∃v. [T][v])
which cannot guarantee the length of the slice doesn't change (the length of a slice cannot change but the type can't guarantee it). Since we are casting&mut [T; n]
to&mut [T][n]
the call toreverse
fails because&mut [T][n]
is not a subtype of&mut ∃v. [T][v]
.The text was updated successfully, but these errors were encountered: