rust/tests/compile-fail/pointer_byte_read_2.rs

8 lines
257 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
2018-11-26 08:31:53 -06:00
let _val = unsafe { *z }; //~ ERROR tried to access part of a pointer value as raw bytes
}