Description
Summary
Does this code have UB?
fn main() {
let ptr = 32 as *const (u8, u8);
unsafe {
match (*ptr).1 { _ => {} }
}
}
Currently the answer Miri gives is no. That is inconsistent with let _ = (*ptr).1
, which creates a PlaceMention
that is picked up by Miri and hence raises UB (the UB error will change with rust-lang/rust#114330, since it will be UB at the projection rather than the deref, but it will remain UB).
We should determine whether we want to make this behavior consistent.
Reading
Issues/PRs:
- Allow partially moved values in match rust#103208
- Miri misses UB in place expressions when there are "_" patterns miri#2360
Comment policy
These issues are meant to be used as an "announcements channel" regarding the proposal, and not as a
place to discuss the technical details. Feel free to subscribe to updates. We'll post comments when
reviewing the proposal in meetings or making a scheduling decision. In the meantime, if you have
questions or ideas, ping the proposers on Zulip (or elsewhere).