add test for int -> fn ptr cast
This commit is contained in:
parent
2c34d6558c
commit
511fa40d23
@ -61,7 +61,7 @@ impl<'tcx> Error for EvalError<'tcx> {
|
||||
EvalError::DanglingPointerDeref =>
|
||||
"dangling pointer was dereferenced",
|
||||
EvalError::InvalidFunctionPointer =>
|
||||
"tried to use an integer pointer as a function pointer",
|
||||
"tried to use an integer pointer or a dangling pointer as a function pointer",
|
||||
EvalError::InvalidBool =>
|
||||
"invalid boolean value read",
|
||||
EvalError::InvalidDiscriminant =>
|
||||
|
8
tests/compile-fail/cast_box_int_to_fn_ptr.rs
Normal file
8
tests/compile-fail/cast_box_int_to_fn_ptr.rs
Normal file
@ -0,0 +1,8 @@
|
||||
fn main() {
|
||||
let b = Box::new(42);
|
||||
let g = unsafe {
|
||||
std::mem::transmute::<&usize, &fn(i32)>(&b)
|
||||
};
|
||||
|
||||
(*g)(42) //~ ERROR tried to use an integer pointer or a dangling pointer as a function pointer
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user