rust/tests/compile-fail/cast_int_to_fn_ptr.rs

8 lines
189 B
Rust
Raw Normal View History

fn main() {
let g = unsafe {
std::mem::transmute::<usize, fn(i32)>(42)
};
g(42) //~ ERROR tried to use an integer pointer or a dangling pointer as a function pointer
}