make use of get_alloc_info

This commit is contained in:
Ralf Jung
2022-06-27 11:09:28 -04:00
parent 7fafbde038
commit 098704e10f
5 changed files with 20 additions and 34 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ fn f() {}
fn main() {
let x: u8 = unsafe {
*std::mem::transmute::<fn(), *const u8>(f) //~ ERROR contains a function
*std::mem::transmute::<fn(), *const u8>(f) //~ ERROR out-of-bounds
};
panic!("this should never print: {}", x);
}
@@ -1,8 +1,8 @@
error: Undefined Behavior: accessing ALLOC which contains a function
error: Undefined Behavior: dereferencing pointer failed: ALLOC has size 0, so pointer to 1 byte starting at offset 0 is out-of-bounds
--> $DIR/deref_fn_ptr.rs:LL:CC
|
LL | *std::mem::transmute::<fn(), *const u8>(f)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ accessing ALLOC which contains a function
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC has size 0, so pointer to 1 byte starting at offset 0 is out-of-bounds
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information