]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/intrinsics/copy_unaligned.rs
move error-pattern to inline annotation where possible
[rust.git] / tests / compile-fail / intrinsics / copy_unaligned.rs
1 #![feature(intrinsics)]
2
3 // Directly call intrinsic to avoid debug assertions in libstd
4 extern "rust-intrinsic" {
5     fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
6 }
7
8 fn main() {
9     let mut data = [0u16; 8];
10     let ptr = (&mut data[0] as *mut u16 as *mut u8).wrapping_add(1) as *mut u16;
11     // Even copying 0 elements to something unaligned should error
12     unsafe { copy_nonoverlapping(&data[5], ptr, 0); } //~ ERROR accessing memory with alignment 1, but alignment 2 is required
13 }