Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dereferencing struct member after mutation gives different results in Rust 1.45 compared with 1.44 #74740

Closed
peterjoel opened this issue Jul 25, 2020 · 1 comment
Labels
C-bug Category: This is a bug.

Comments

@peterjoel
Copy link
Contributor

This was mentioned by a user on stackoverflow.

struct Foo {
    x: i32,
}

fn main() {
    let mut foo = Foo { x: 42 };
    let x = &mut foo.x;
    *x = 13;
    let y = foo;
    println!("{}", y.x);
}

Rust 1.45 outputs:

42

Rust 1.44 outputs:

13

It seems to be fixed in Nightly and Beta. Only 1.45 has the problem.

I tried this code:

@peterjoel peterjoel added the C-bug Category: This is a bug. label Jul 25, 2020
@peterjoel
Copy link
Contributor Author

This can be resolved as a duplicate of #74739

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

1 participant