]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/issue-32947.rs
New upstream version 1.19.0+dfsg1
[rustc.git] / src / test / run-pass / issue-32947.rs
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.
4 //
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.
10
11 #![feature(repr_simd, test)]
12
13 extern crate test;
14
15 #[repr(simd)]
16 pub struct Mu64(pub u64, pub u64, pub u64, pub u64);
17
18 fn main() {
19 // This ensures an unaligned pointer even in optimized builds, though LLVM
20 // gets enough type information to actually not mess things up in that case,
21 // but at the time of writing this, it's enough to trigger the bug in
22 // non-optimized builds
23 unsafe {
24 let memory = &mut [0u64; 8] as *mut _ as *mut u8;
25 let misaligned_ptr: &mut [u8; 32] = {
26 std::mem::transmute(memory.offset(1))
27 };
28 *misaligned_ptr = std::mem::transmute(Mu64(1, 1, 1, 1));
29 test::black_box(memory);
30 }
31 }