rust/tests/fail/function_pointers/execute_memory.rs

13 lines
306 B
Rust
Raw Normal View History

// Validation makes this fail in the wrong place
2022-07-08 11:08:32 -05:00
//@compile-flags: -Zmiri-disable-validation
#![feature(box_syntax)]
2016-06-13 05:29:01 -05:00
2016-08-27 02:44:46 -05:00
fn main() {
let x = box 42;
2016-06-13 05:29:01 -05:00
unsafe {
let f = std::mem::transmute::<Box<i32>, fn()>(x);
f() //~ ERROR: function pointer but it does not point to a function
2016-06-13 05:29:01 -05:00
}
}