rust/tests/compile-fail/deref_fn_ptr.rs

9 lines
204 B
Rust
Raw Normal View History

2016-06-13 05:29:01 -05:00
fn f() {}
fn main() {
let x: u8 = unsafe {
2019-04-21 06:18:05 -05:00
*std::mem::transmute::<fn(), *const u8>(f) //~ ERROR tried to dereference a function pointer
};
panic!("this should never print: {}", x);
2016-06-13 05:29:01 -05:00
}