2022-07-05 04:15:22 -05:00
|
|
|
//@compile-flags: -Zmiri-strict-provenance
|
2022-06-05 10:47:39 -05:00
|
|
|
#![feature(strict_provenance)]
|
2022-04-01 13:10:24 -05:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let x = 22;
|
|
|
|
let ptr = &x as *const _ as *const u8;
|
2022-06-05 10:47:39 -05:00
|
|
|
let roundtrip = std::ptr::invalid::<u8>(ptr as usize);
|
|
|
|
// Not even offsetting this is allowed.
|
2022-07-24 13:28:45 -05:00
|
|
|
let _ = unsafe { roundtrip.offset(1) }; //~ERROR: is a dangling pointer
|
2022-04-01 13:10:24 -05:00
|
|
|
}
|