-
Notifications
You must be signed in to change notification settings - Fork 391
Open
Labels
A-validationArea: This affects enforcing the validity invariant, and related UB checkingArea: This affects enforcing the validity invariant, and related UB checkingC-enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancement
Description
According to rust-lang/rust#78123 (comment) and the Reference, producing an &
-reference (not sure about raw pointers) to an invalid value is instant UB:
Unlike C, Undefined Behavior is pretty limited in scope in Rust. All the core language cares about is preventing the following things:
[...]
a reference/Box
that is dangling, unaligned, or points to an invalid value.
For example, if I understand correctly, this program has UB, but Miri does not report any errors:
enum Void {}
fn main() {
let _x: &Void = unsafe { std::mem::transmute(&()) };
}
Metadata
Metadata
Assignees
Labels
A-validationArea: This affects enforcing the validity invariant, and related UB checkingArea: This affects enforcing the validity invariant, and related UB checkingC-enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancement