2020-10-28 07:50:27 -05:00
|
|
|
//! This demonstrates a provenance problem that requires tracking of raw pointers to be detected.
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut l = 13;
|
|
|
|
let raw1 = &mut l as *mut _;
|
|
|
|
let raw2 = &mut l as *mut _; // invalidates raw1
|
|
|
|
// Without raw pointer tracking, Stacked Borrows cannot distinguish raw1 and raw2, and thus
|
|
|
|
// fails to realize that raw1 should not be used any more.
|
2022-07-13 17:59:33 -05:00
|
|
|
unsafe { *raw1 = 13 }; //~ ERROR: /write access .* tag does not exist in the borrow stack/
|
2022-06-25 22:30:29 -05:00
|
|
|
unsafe { *raw2 = 13 };
|
2020-10-28 07:50:27 -05:00
|
|
|
}
|