mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-31 21:47:15 +03:00
Auto merge of #3010 - RalfJung:assign_overlapping, r=RalfJung
add test checking that overlapping assignments work
This commit is contained in:
@@ -20,6 +20,15 @@ fn basic_raw() {
|
||||
assert_eq!(*x, 23);
|
||||
}
|
||||
|
||||
fn assign_overlapping() {
|
||||
// Test an assignment where LHS and RHS alias.
|
||||
// In Mir, that's UB (see `fail/overlapping_assignment.rs`), but in surface Rust this is allowed.
|
||||
let mut mem = [0u32; 4];
|
||||
let ptr = &mut mem as *mut [u32; 4];
|
||||
unsafe { *ptr = *ptr };
|
||||
}
|
||||
|
||||
fn main() {
|
||||
basic_raw();
|
||||
assign_overlapping();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user