I'm trying to check if some unsafe code is unsound, and for this, I need different "allocated objects" with consecutive addresses, like this:
let a = 2;
let b = 1;
assert_eq!(
&b as *const _ as usize - &a as *const _ as usize,
core::mem::size_of::<i32>()
);
This passes when compiled with rustc
, but fails with miri
. It seems like miri
randomized variable addresses. Is it possible to make this pass with miri
?