Closed
Description
It is impossible to read a filed of uninitialized struct, but for some reason the write is allowed (but you can't read it back later):
struct S {x: i32, y: i32}
fn main() {
let mut s: S;
s.x = 32; // why I don't get an error here,
s.y = 12;
println!("{}", s.x) // but get it here instead?
}
Originally reported at https://users.rust-lang.org/t/use-of-possibly-uninitialized-variable-on-an-initialized-variable/4799/4
Metadata
Metadata
Assignees
Labels
No labels