2020-04-14 09:58:58 +02:00
|
|
|
// Make sure we find these even with many checks disabled.
|
2022-07-08 16:08:32 +00:00
|
|
|
//@compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
|
2020-04-14 09:58:58 +02:00
|
|
|
|
2021-07-18 12:47:04 +02:00
|
|
|
// Test what happens when we overwrite parts of a pointer.
|
2022-06-03 08:46:22 -04:00
|
|
|
// Also see <https://github.com/rust-lang/miri/issues/2181>.
|
2021-07-18 12:47:04 +02:00
|
|
|
|
2016-06-13 14:27:05 +02:00
|
|
|
fn main() {
|
|
|
|
let mut p = &42;
|
|
|
|
unsafe {
|
|
|
|
let ptr: *mut _ = &mut p;
|
|
|
|
*(ptr as *mut u8) = 123; // if we ever support 8 bit pointers, this is gonna cause
|
|
|
|
// "attempted to interpret some raw bytes as a pointer address" instead of
|
|
|
|
// "attempted to read undefined bytes"
|
|
|
|
}
|
2022-07-11 11:44:55 +00:00
|
|
|
let x = *p; //~ ERROR: this operation requires initialized memory
|
2016-06-13 14:27:05 +02:00
|
|
|
panic!("this should never print: {}", x);
|
|
|
|
}
|