rust/tests/compile-fail/pointer_byte_read.rs

8 lines
247 B
Rust
Raw Normal View History

fn main() {
let x = 13;
let y = &x;
let z = &y as *const &i32 as *const u8;
// the deref fails, because we are reading only a part of the pointer
2020-03-08 17:34:54 -05:00
let _val = unsafe { *z }; //~ ERROR unable to turn this pointer into raw bytes
}