The current alignment check does not include checks for creating misaligned references from raw pointers, which is now added in this patch. When inserting the check we need to be careful with references to field projections (e.g. `&(*ptr).a`), in which case the resulting reference must be aligned according to the field type and not the type of the pointer.
13 lines
310 B
Rust
13 lines
310 B
Rust
//@ run-fail
|
|
//@ ignore-i686-pc-windows-msvc: #112480
|
|
//@ compile-flags: -C debug-assertions
|
|
//@ error-pattern: misaligned pointer dereference: address must be a multiple of 0x4 but is
|
|
|
|
fn main() {
|
|
let x = [0u32; 2];
|
|
let ptr = x.as_ptr();
|
|
unsafe {
|
|
let _ptr = &(*(ptr.byte_add(1)));
|
|
}
|
|
}
|