72664e42aa
This breaks creating unaligned raw pointers via `&packed.field as *const _`, which needs to be legal. Also it doesn't seem like LLVM still relies on this, see * https://github.com/solson/miri/issues/244#issuecomment-315563640 * https://internals.rust-lang.org/t/rules-for-alignment-and-non-nullness-of-references/5430/16 We probably want to handle this invariant like the others that validation is concerned with, and only check it on function boundaries for now.
7 lines
234 B
Rust
7 lines
234 B
Rust
fn main() {
|
|
let x = &2u16;
|
|
let x = x as *const _ as *const u32;
|
|
// This must fail because alignment is violated
|
|
let _x = unsafe { *x }; //~ ERROR: tried to access memory with alignment 2, but alignment 4 is required
|
|
}
|