]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/copy_null.rs
fix compile-fail tests to avoid libstd debug assertions
[rust.git] / tests / compile-fail / copy_null.rs
1 //error-pattern: invalid use of NULL pointer
2 #![feature(intrinsics)]
3
4 // Directly call intrinsic to avoid debug assertions in libstd
5 extern "rust-intrinsic" {
6     fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
7 }
8
9 fn main() {
10     let mut data = [0u16; 4];
11     let ptr = &mut data[0] as *mut u16;
12     // Even copying 0 elements from NULL should error.
13     unsafe { copy_nonoverlapping(std::ptr::null(), ptr, 0); }
14 }