rust/tests/ui/consts/const-eval/partial_ptr_overwrite.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

13 lines
310 B
Rust
Raw Permalink Normal View History

2021-07-31 09:52:59 +00:00
// Test for the behavior described in <https://github.com/rust-lang/rust/issues/87184>.
const PARTIAL_OVERWRITE: () = {
let mut p = &42;
unsafe {
let ptr: *mut _ = &mut p;
*(ptr as *mut u8) = 123; //~ ERROR unable to overwrite parts of a pointer
2021-07-31 09:52:59 +00:00
}
let x = *p;
};
fn main() {}