]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/copy_null.rs
08391b12ae1bc620ae724a718f76c8855f5571a2
[rust.git] / tests / compile-fail / copy_null.rs
1 //error-pattern: invalid use of NULL pointer
2
3 fn main() {
4     let mut data = [0u16; 4];
5     let ptr = &mut data[0] as *mut u16;
6     // Even copying 0 elements from NULL should error.
7     unsafe { ptr.copy_from(std::ptr::null(), 0); }
8 }