Rudra
Rudra copied to clipboard
Unsafe Dataflow Detection Issue Related to Reference Handling
Hi, Rudra fails to detect an unsafe data flow issue in the following program, which appears to be a false negative. This issue seems to be related to reference handling.
use std::ptr;
fn insertion_sort_unsafe<T: Ord>(arr: &mut [T]) {
unsafe {
for i in 1..arr.len() {
let item = ptr::read(&arr[i]);
let mut j = i - 1;
while j >= 0 && &arr[j] > &item{
j = j - 1;
}
ptr::copy(&mut arr[j + 1], &mut arr[j + 2], i - j - 1);
ptr::write(&mut arr[j + 1], item);
}
}
}
pub fn main() {
let mut arr = [3, 2, 1];
insertion_sort_unsafe(&mut arr);
}