-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Listing 19-03 is potentially UB under Stacked Borrows #3014
Comments
You don’t need any flags anymore. I believe since |
Hi, I just found this issue. I think a better fix would be to use (and explain) The problem here is that the temporary I also think that this is a great opportunity to warn and/or illustrate what can go wrong with unsafe, and maybe introduce miri. IMO, the best fix would be to leave the listing as is, explain and illustrate with miri why it's wrong, then provide a correct version. |
Oooof. We definitely don’t want unsound code in our example of |
main
branch to see if this has already been fixedURL to the section(s) of the book with this problem: https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html#dereferencing-a-raw-pointer
Description of the problem: Running the listing
Under MIRI with
MIRIFLAGS="-Zmiri-symbolic-alignment-check -Zmiri-check-number-validity -Zmiri-tag-raw-pointers"
results in the following:Suggested fix:
I'm not sure. The following fixes that specific problem:
But I'm not sure if it preserves the original meaning
Possibly related: rust-lang/unsafe-code-guidelines#133
The text was updated successfully, but these errors were encountered: