2022-07-08 16:08:32 +00:00
|
|
|
//@compile-flags: -Zmiri-permissive-provenance
|
2022-06-26 21:26:14 -04:00
|
|
|
|
2018-10-12 10:54:37 +02:00
|
|
|
fn main() {
|
|
|
|
// Cast a function pointer such that on a call, the argument gets transmuted
|
2019-02-16 01:43:56 +00:00
|
|
|
// from raw ptr to reference. This is ABI-compatible, so it's not the call that
|
2018-10-12 10:54:37 +02:00
|
|
|
// should fail, but validation should.
|
2022-06-21 11:27:44 -07:00
|
|
|
fn f(_x: &i32) {}
|
2018-10-12 10:54:37 +02:00
|
|
|
|
|
|
|
let g: fn(*const i32) = unsafe { std::mem::transmute(f as fn(&i32)) };
|
|
|
|
|
2019-02-16 01:43:56 +00:00
|
|
|
g(0usize as *const i32)
|
2021-05-04 15:53:19 +08:00
|
|
|
//~^ ERROR encountered a null reference
|
2018-10-12 10:54:37 +02:00
|
|
|
}
|