Update all tests
This commit is contained in:
parent
b64a1c46c6
commit
8acfbc3b33
@ -9,5 +9,5 @@ fn main() {
|
||||
let mut data = [0u16; 8];
|
||||
let ptr = (&mut data[0] as *mut u16 as *mut u8).wrapping_add(1) as *mut u16;
|
||||
// Even copying 0 elements to something unaligned should error
|
||||
unsafe { copy_nonoverlapping(&data[5], ptr, 0); } //~ ERROR accessing memory with alignment ALIGN, but alignment ALIGN is required
|
||||
unsafe { copy_nonoverlapping(&data[5], ptr, 0); } //~ ERROR accessing memory with alignment 1, but alignment 2 is required
|
||||
}
|
||||
|
@ -3,6 +3,6 @@ static X: usize = 5;
|
||||
#[allow(mutable_transmutes)]
|
||||
fn main() {
|
||||
let _x = unsafe {
|
||||
std::mem::transmute::<&usize, &mut usize>(&X) //~ ERROR writing to ALLOC which is read-only
|
||||
std::mem::transmute::<&usize, &mut usize>(&X) //~ ERROR writing to alloc1 which is read-only
|
||||
};
|
||||
}
|
||||
|
@ -16,6 +16,6 @@ fn main() {
|
||||
// Overwrite the data part of `ptr` so it points to `buf`.
|
||||
unsafe { (&mut ptr as *mut _ as *mut *const u8).write(&buf as *const _ as *const u8); }
|
||||
// Re-borrow that. This should be UB.
|
||||
let _ptr = &*ptr; //~ERROR alignment ALIGN is required
|
||||
let _ptr = &*ptr; //~ERROR alignment 256 is required
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ fn main() {
|
||||
// Manually make sure the pointer is properly aligned.
|
||||
let base_addr_aligned = if base_addr % 2 == 0 { base_addr } else { base_addr+1 };
|
||||
let u16_ptr = base_addr_aligned as *mut u16;
|
||||
unsafe { *u16_ptr = 2; } //~ERROR memory with alignment ALIGN, but alignment ALIGN is required
|
||||
unsafe { *u16_ptr = 2; } //~ERROR memory with alignment 1, but alignment 2 is required
|
||||
println!("{:?}", x);
|
||||
}
|
||||
|
@ -16,6 +16,6 @@ fn main() {
|
||||
y: 99,
|
||||
};
|
||||
let p = &foo.x;
|
||||
let i = *p; //~ERROR alignment ALIGN is required
|
||||
let i = *p; //~ERROR alignment 4 is required
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ fn main() {
|
||||
let x = [2u16, 3, 4]; // Make it big enough so we don't get an out-of-bounds error.
|
||||
let x = &x[0] as *const _ as *const u32;
|
||||
// This must fail because alignment is violated: the allocation's base is not sufficiently aligned.
|
||||
let _x = unsafe { *x }; //~ERROR memory with alignment ALIGN, but alignment ALIGN is required
|
||||
let _x = unsafe { *x }; //~ERROR memory with alignment 2, but alignment 4 is required
|
||||
}
|
||||
}
|
||||
|
@ -8,5 +8,5 @@ fn main() {
|
||||
let x = (x.as_ptr() as *const u8).wrapping_offset(3) as *const u32;
|
||||
// This must fail because alignment is violated: the offset is not sufficiently aligned.
|
||||
// Also make the offset not a power of 2, that used to ICE.
|
||||
let _x = unsafe { *x }; //~ERROR memory with alignment ALIGN, but alignment ALIGN is required
|
||||
let _x = unsafe { *x }; //~ERROR memory with alignment 1, but alignment 4 is required
|
||||
}
|
||||
|
@ -8,6 +8,6 @@ fn main() {
|
||||
let x = &x[0] as *const _ as *const u32;
|
||||
// This must fail because alignment is violated: the allocation's base is not sufficiently aligned.
|
||||
// The deref is UB even if we just put the result into a raw pointer.
|
||||
let _x = unsafe { ptr::addr_of!(*x) }; //~ ERROR memory with alignment ALIGN, but alignment ALIGN is required
|
||||
let _x = unsafe { ptr::addr_of!(*x) }; //~ ERROR memory with alignment 2, but alignment 4 is required
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,6 @@ fn main() {
|
||||
let x = i as u8;
|
||||
let x = &x as *const _ as *const [u32; 0];
|
||||
// This must fail because alignment is violated. Test specifically for loading ZST.
|
||||
let _x = unsafe { *x }; //~ERROR alignment ALIGN is required
|
||||
let _x = unsafe { *x }; //~ERROR alignment 4 is required
|
||||
}
|
||||
}
|
||||
|
@ -3,5 +3,5 @@
|
||||
use std::mem;
|
||||
|
||||
fn main() {
|
||||
let _x: &i32 = unsafe { mem::transmute(16usize) }; //~ ERROR encountered a dangling reference (address $HEX is unallocated)
|
||||
let _x: &i32 = unsafe { mem::transmute(16usize) }; //~ ERROR encountered a dangling reference (address 0x10 is unallocated)
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
fn main() {
|
||||
assert!(std::char::from_u32(-1_i32 as u32).is_none());
|
||||
let _val = match unsafe { std::mem::transmute::<i32, char>(-1) } { //~ ERROR encountered $HEX, but expected a valid unicode scalar value
|
||||
let _val = match unsafe { std::mem::transmute::<i32, char>(-1) } { //~ ERROR encountered 0xffffffff, but expected a valid unicode scalar value
|
||||
'a' => {true},
|
||||
'b' => {false},
|
||||
_ => {true},
|
||||
|
Loading…
x
Reference in New Issue
Block a user