Closed
Description
#![feature(thread_local)]
#[thread_local]
static S: &str = "before";
fn set_s() {
S = "after";
}
fn main() {
println!("{}", S);
set_s();
println!("{}", S);
}
On rustc 1.31.0-nightly (b2d6ea9 2018-10-07) and x86_64-unknown-linux-gnu, we see the following surprising behavior:
$ cargo run # as expected
before
after
$ cargo run --release
before
before
In release mode it seems the write has not happened in the place that it should.
Mentioning thread_local tracking issue: rust-lang/rust#29594.