rust/tests/compile-fail/deref_fn_ptr.rs
2019-04-21 13:18:05 +02:00

9 lines
204 B
Rust

fn f() {}
fn main() {
let x: u8 = unsafe {
*std::mem::transmute::<fn(), *const u8>(f) //~ ERROR tried to dereference a function pointer
};
panic!("this should never print: {}", x);
}