mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-31 13:40:15 +03:00
add test for int -> fn ptr cast
This commit is contained in:
+1
-1
@@ -61,7 +61,7 @@ fn description(&self) -> &str {
|
||||
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 =>
|
||||
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user