about summary refs log tree commit diff
path: root/src/tools/miri/tests/fail/uninit/padding-struct.rs
blob: 4cdc6f3a1045028d935e98d1dc0caf2c734170bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use std::mem;

#[repr(C)]
struct Pair(u8, u16);

fn main() {
    unsafe {
        let p: Pair = mem::transmute(0u32); // The copy when `Pair` is returned from `transmute` should destroy padding.
        let c = &p as *const _ as *const u8;
        // Read the padding byte.
        let _val = *c.add(1);
        //~^ERROR: uninitialized
    }
}