-
Notifications
You must be signed in to change notification settings - Fork 353
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
Miri checks ptr.read()
but not dereferencing a pointer (*ptr)
#1526
Comments
I just tried on the playground, and I do get an error for the second example as well:
|
Ha, you're right, this is weird. fn main() {
unsafe {
let a = [1u8, 2, 3];
let b = &a[0] as *const u8;
if !a.is_empty() {
println!("{}", *b.add(1));
}
}
} |
But neither does this: fn main() {
unsafe {
let a = [1u8, 2, 3];
let b = &a[0] as *const u8;
if !a.is_empty() {
println!("{}", b.add(1).read());
}
}
} |
This has nothing to do with deref vs |
@RalfJung Yes. this is a completely different issue than what I was describing, |
So together with my confusion and the fact that this is expected behavior I'll close this issue. |
I opened rust-lang/unsafe-code-guidelines#248 to track the underlying problem. |
…alfJung Fix potential UB in align_offset doc examples Currently it takes a pointer only to the first element in the array, this changes the code to take a pointer to the whole array. miri can't catch this right now because it later calls `x.len()` which re-tags the pointer for the whole array. rust-lang/miri#1526 (comment)
Hi,
miri complains on this:
https://play.rust-lang.org/?gist=5af194a447ac5e0d38796c809e3a0e6f
but not on this:
https://play.rust-lang.org/?gist=6b7d13c8b77d8e14e06d9133a19e992f
The text was updated successfully, but these errors were encountered: