]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/copy_null.rs
Auto merge of #1308 - RalfJung:miri, r=RalfJung
[rust.git] / tests / compile-fail / copy_null.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; 4];
10     let ptr = &mut data[0] as *mut u16;
11     // Even copying 0 elements from NULL should error.
12     unsafe { copy_nonoverlapping(std::ptr::null(), ptr, 0); } //~ ERROR: invalid use of NULL pointer
13 }