Open
Description
In the community Discord, someone recently found a bug in their code (or idea?) because the address of a const value wasn't stable in miri, but was stable in normal execution.
As demonstration, someone posted this example:
const FOO: &str = "";
fn main() {
println!("{:p}", FOO);
println!("{:p}", FOO);
}
Which on the playground currently prints
0x25ea8
0x2d638
But then OP responded with this example:
const FOO: &&str = &"";
fn main() {
println!("{:p}", *FOO);
println!("{:p}", *FOO);
println!("{:p}", *FOO);
}
Which on the playground currently prints
0x25e96
0x25e96
0x25e96
This seems less-than-awesome. Is there something that miri can do to make sure that addresses of consts aren't accidentally stable across instantiations? Or at least, are very unlikely to be stable?