about summary refs log tree commit diff
path: root/src/tools/miri/tests/fail/validity/too-big-unsized.rs
blob: 280205dccbf238a744c0137a014d9a7f842eb48a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::mem;

#[allow(unused)]
struct MySlice {
    prefix: u64,
    tail: [u8],
}

fn main() {
    unsafe {
        let ptr = Box::into_raw(Box::new(0u8));
        // The slice part is actually not "too big", but together with the `prefix` field it is.
        let _x: &MySlice = mem::transmute((ptr, isize::MAX as usize)); //~ ERROR: invalid reference metadata: total size is bigger than largest supported object
    }
}