2016-04-06 05:19:36 -05:00
|
|
|
#![feature(custom_attribute)]
|
|
|
|
#![allow(dead_code, unused_attributes)]
|
|
|
|
|
|
|
|
#[miri_run]
|
|
|
|
fn overwriting_part_of_relocation_makes_the_rest_undefined() -> i32 {
|
2016-04-06 05:24:35 -05:00
|
|
|
let mut p = &42;
|
2016-04-06 05:19:36 -05:00
|
|
|
unsafe {
|
2016-04-06 05:24:35 -05:00
|
|
|
let ptr: *mut _ = &mut p;
|
|
|
|
*(ptr as *mut u32) = 123;
|
2016-04-06 05:19:36 -05:00
|
|
|
}
|
2016-04-06 05:24:35 -05:00
|
|
|
*p
|
|
|
|
}
|
|
|
|
|
|
|
|
#[miri_run]
|
|
|
|
fn pointers_to_different_allocations_are_unorderable() -> bool {
|
|
|
|
let x: *const u8 = &1;
|
|
|
|
let y: *const u8 = &2;
|
|
|
|
x < y
|
2016-04-06 05:19:36 -05:00
|
|
|
}
|
2016-04-06 05:27:09 -05:00
|
|
|
|
|
|
|
#[miri_run]
|
|
|
|
fn invalid_bools_are_rejected() -> u8 {
|
|
|
|
let b = unsafe { std::mem::transmute::<u8, bool>(2) };
|
|
|
|
if b { 1 } else { 2 }
|
|
|
|
}
|