1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // write_volatile causes an LLVM assert with composite types
13 // ignore-emscripten See #41299: probably a bad optimization
16 use std::ptr::{read_volatile, write_volatile};
18 #[derive(Debug, Eq, PartialEq)]
20 #[derive(Debug, Eq, PartialEq)]
22 #[derive(Debug, Eq, PartialEq)]
24 #[derive(Debug, Eq, PartialEq)]
26 #[derive(Debug, Eq, PartialEq)]
32 write_volatile(&mut x, 1);
33 assert_eq!(read_volatile(&x), 1);
37 write_volatile(&mut x, 1);
38 assert_eq!(read_volatile(&x), 1);
42 write_volatile(&mut x, A(1));
43 assert_eq!(read_volatile(&x), A(1));
47 write_volatile(&mut x, B(1));
48 assert_eq!(read_volatile(&x), B(1));
52 write_volatile(&mut x, C(1, 1));
53 assert_eq!(read_volatile(&x), C(1, 1));
54 assert_eq!(x, C(1, 1));
57 write_volatile(&mut x, D(1, 1));
58 assert_eq!(read_volatile(&x), D(1, 1));
59 assert_eq!(x, D(1, 1));
61 let mut x = E([0; 32]);
62 write_volatile(&mut x, E([1; 32]));
63 assert_eq!(read_volatile(&x), E([1; 32]));
64 assert_eq!(x, E([1; 32]));