2020-02-24 09:22:02 -06:00
|
|
|
// Stacked Borrows disallows this becuase the reference is never cast to a raw pointer.
|
2022-07-08 11:08:32 -05:00
|
|
|
//@compile-flags: -Zmiri-disable-stacked-borrows
|
2019-07-03 03:19:55 -05:00
|
|
|
|
2018-08-14 11:51:15 -05:00
|
|
|
fn main() {
|
|
|
|
// If we are careful, we can exploit data layout...
|
2022-07-02 20:17:35 -05:00
|
|
|
// This is a tricky case since we are transmuting a ScalarPair type to a non-ScalarPair type.
|
2022-06-21 01:40:39 -05:00
|
|
|
let raw = unsafe { std::mem::transmute::<&[u8], [*const u8; 2]>(&[42]) };
|
2022-06-06 10:44:36 -05:00
|
|
|
let ptr: *const u8 = unsafe { std::mem::transmute_copy(&raw) };
|
|
|
|
assert_eq!(unsafe { *ptr }, 42);
|
2018-08-14 11:51:15 -05:00
|
|
|
}
|