mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 01:34:21 +00:00
17 lines
287 B
Rust
17 lines
287 B
Rust
|
//@ run-pass
|
||
|
//@ compile-flags: -C debug-assertions
|
||
|
|
||
|
#[repr(align(8))]
|
||
|
struct Misalignment {
|
||
|
a: u8,
|
||
|
}
|
||
|
|
||
|
fn main() {
|
||
|
let mem = 0u64;
|
||
|
let ptr = &mem as *const u64 as *const Misalignment;
|
||
|
unsafe {
|
||
|
let ptr = ptr.byte_add(1);
|
||
|
let _ref: &u8 = &(*ptr).a;
|
||
|
}
|
||
|
}
|