2 #![feature(custom_attribute)]
3 #![allow(dead_code, unused_attributes)]
6 fn overwriting_part_of_relocation_makes_the_rest_undefined() -> i32 {
9 let ptr: *mut _ = &mut p;
10 *(ptr as *mut u32) = 123;
16 fn pointers_to_different_allocations_are_unorderable() -> bool {
17 let x: *const u8 = &1;
18 let y: *const u8 = &2;
23 fn invalid_bool() -> u8 {
24 let b = unsafe { std::mem::transmute::<u8, bool>(2) };
29 fn undefined_byte_read() -> u8 {
30 let v: Vec<u8> = Vec::with_capacity(10);
31 let undef = unsafe { *v.get_unchecked(5) };
36 fn out_of_bounds_read() -> u8 {
37 let v: Vec<u8> = vec![1, 2];
38 unsafe { *v.get_unchecked(5) }
42 fn dangling_pointer_deref() -> i32 {