]> git.proxmox.com Git - rustc.git/blame - src/test/ui/issues/issue-39827.rs
New upstream version 1.60.0+dfsg1
[rustc.git] / src / test / ui / issues / issue-39827.rs
CommitLineData
b7449926 1// run-pass
3b2f2976
XL
2#![feature(core_intrinsics)]
3
4use 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//
13fn 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}