2018-08-30 14:18:55 +02:00
|
|
|
// run-pass
|
2018-09-25 23:51:35 +02:00
|
|
|
#![allow(dead_code)]
|
2017-11-16 19:12:23 +01:00
|
|
|
#[repr(packed)]
|
|
|
|
pub struct Good {
|
|
|
|
data: &'static u32,
|
|
|
|
data2: [&'static u32; 2],
|
|
|
|
aligned: [u8; 32],
|
|
|
|
}
|
|
|
|
|
|
|
|
// kill this test when that turns to a hard error
|
2021-02-25 19:38:53 +01:00
|
|
|
#[allow(unaligned_references)]
|
2017-11-16 19:12:23 +01:00
|
|
|
fn main() {
|
2020-05-16 16:29:27 +02:00
|
|
|
let good = Good { data: &0, data2: [&0, &0], aligned: [0; 32] };
|
2017-11-16 19:12:23 +01:00
|
|
|
|
2021-02-25 19:38:53 +01:00
|
|
|
let _ = &good.data; // ok
|
|
|
|
let _ = &good.data2[0]; // ok
|
2017-11-16 19:12:23 +01:00
|
|
|
|
|
|
|
let _ = &good.data;
|
|
|
|
let _ = &good.data2[0];
|
|
|
|
let _ = &*good.data; // ok, behind a pointer
|
|
|
|
let _ = &good.aligned; // ok, has align 1
|
|
|
|
let _ = &good.aligned[2]; // ok, has align 1
|
|
|
|
}
|