]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-39827.rs
Merge commit 'b40ea209e7f14c8193ddfc98143967b6a2f4f5c9' into clippyup
[rust.git] / src / test / ui / issues / issue-39827.rs
1 // run-pass
2 #![feature(core_intrinsics)]
3
4 use std::intrinsics::{ volatile_copy_memory, volatile_store, volatile_load,
5                        volatile_copy_nonoverlapping_memory,
6                        volatile_set_memory };
7
8 //
9 // This test ensures that volatile intrinsics can be specialised with
10 // zero-sized types and, in case of copy/set functions, can accept
11 // number of elements equal to zero.
12 //
13 fn main () {
14     let mut dst_pair = (1, 2);
15     let src_pair = (3, 4);
16     let mut dst_empty = ();
17     let src_empty = ();
18
19     const COUNT_0: usize = 0;
20     const COUNT_100: usize = 100;
21
22     unsafe {
23         volatile_copy_memory(&mut dst_pair, &dst_pair, COUNT_0);
24         volatile_copy_nonoverlapping_memory(&mut dst_pair, &src_pair, 0);
25         volatile_copy_memory(&mut dst_empty, &dst_empty, 100);
26         volatile_copy_nonoverlapping_memory(&mut dst_empty, &src_empty,
27                                             COUNT_100);
28         volatile_set_memory(&mut dst_empty, 0, COUNT_100);
29         volatile_set_memory(&mut dst_pair, 0, COUNT_0);
30         volatile_store(&mut dst_empty, ());
31         volatile_store(&mut dst_empty, src_empty);
32         volatile_load(&src_empty);
33     }
34 }