Closed as duplicate of#128775
Closed as duplicate of#128775
Description
Technically not the address of the static
itself, but it is a confusing interaction
I tried this code:
mod m {
pub static IN_MOD: &str = &"s";
pub static IN_MOD_2: &str = IN_MOD;
}
static OUTSIDE: &str = m::IN_MOD;
fn main() {
println!("{:p}", m::IN_MOD);
println!("{:p}", m::IN_MOD_2);
println!("{:p}", OUTSIDE);
}
I expected to see this happen:
The same address printed 3 times as it is on Linux
Instead, this happened:
0x7ff6dba2a370
0x7ff6dba2a370
0x7ff6dba2a3c8
In --release
mode the three addresses are the same
Meta
Stable behaves the same
rustc --version --verbose
:
rustc 1.81.0-nightly (35b658fb1 2024-07-08)
binary: rustc
commit-hash: 35b658fb1071d752d092751d9f17a9fa7b154ec4
commit-date: 2024-07-08
host: x86_64-pc-windows-msvc
release: 1.81.0-nightly
LLVM version: 18.1.7