-
Notifications
You must be signed in to change notification settings - Fork 391
Open
Labels
A-interpreterArea: affects the core interpreterArea: affects the core interpreterA-nondetArea: affects which non-deterministic executions we can exploreArea: affects which non-deterministic executions we can exploreC-spec-questionCategory: it is unclear what the intended behavior of Miri for this case isCategory: it is unclear what the intended behavior of Miri for this case is
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?
Metadata
Metadata
Assignees
Labels
A-interpreterArea: affects the core interpreterArea: affects the core interpreterA-nondetArea: affects which non-deterministic executions we can exploreArea: affects which non-deterministic executions we can exploreC-spec-questionCategory: it is unclear what the intended behavior of Miri for this case isCategory: it is unclear what the intended behavior of Miri for this case is