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