mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 07:44:10 +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;
|
|
}
|
|
}
|