blob: 57b4fd0dedb7cf7d60b5c72a48eca3cd9e6c8f3d [file] [log] [blame]
#![feature(strict_provenance)]
use core::ptr;
fn main() {
unsafe {
let base = ptr::without_provenance::<()>(10);
let unit = &*base;
let p1 = unit as *const ();
let base = ptr::without_provenance::<()>(11);
let unit = &*base;
let p2 = unit as *const ();
// Seems to work because they are same pointer
// even though it's dangling.
let _ = p1.byte_offset_from(p1);
// UB because different pointers.
let _ = p1.byte_offset_from(p2); //~ERROR: different pointers without provenance
}
}