Skip to content

Commit b8cfa76

Browse files
committed
Auto merge of rust-lang#3010 - RalfJung:assign_overlapping, r=RalfJung
add test checking that overlapping assignments work
2 parents 460e92b + 3c39dc2 commit b8cfa76

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/tools/miri/tests/pass/ptr_raw.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ fn basic_raw() {
2020
assert_eq!(*x, 23);
2121
}
2222

23+
fn assign_overlapping() {
24+
// Test an assignment where LHS and RHS alias.
25+
// In Mir, that's UB (see `fail/overlapping_assignment.rs`), but in surface Rust this is allowed.
26+
let mut mem = [0u32; 4];
27+
let ptr = &mut mem as *mut [u32; 4];
28+
unsafe { *ptr = *ptr };
29+
}
30+
2331
fn main() {
2432
basic_raw();
33+
assign_overlapping();
2534
}

0 commit comments

Comments
 (0)