rust/tests/compile-fail/execute_memory.rs

14 lines
354 B
Rust
Raw Normal View History

// Validation makes this fail in the wrong place
// compile-flags: -Zmir-emit-validate=0
#![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 constant evaluation error [E0080]
//~^ NOTE tried to treat a memory pointer as a function pointer
2016-06-13 05:29:01 -05:00
}
}