about summary refs log tree commit diff
path: root/tests/ui/precondition-checks/write_volatile.rs
blob: d6ad6320e41c112f482eea78624c9c9677cc2150 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//@ run-crash
//@ compile-flags: -Copt-level=3 -Cdebug-assertions=no -Zub-checks=yes
//@ error-pattern: unsafe precondition(s) violated: ptr::write_volatile requires
//@ revisions: misaligned

use std::ptr;

fn main() {
    let mut dst = [0u16; 2];
    let mut dst = dst.as_mut_ptr();
    unsafe {
        #[cfg(misaligned)]
        ptr::write_volatile(dst.byte_add(1), 1u16);
    }
}