1
Fork 0

make unaligned_reference a hard error

This commit is contained in:
Ralf Jung 2022-09-30 14:54:30 +02:00
parent f361413cbf
commit dfc4a7b2d0
27 changed files with 170 additions and 686 deletions

View file

@ -1,4 +1,3 @@
// run-pass (note: this is spec-UB, but it works for now)
#![allow(dead_code)]
// ignore-emscripten weird assertion?
@ -20,15 +19,12 @@ struct Foo4C {
baz: usize
}
#[warn(unaligned_references)]
pub fn main() {
let foo = Foo1 { bar: 1, baz: 2 };
let brw = &foo.baz; //~WARN reference to packed field is unaligned
//~^ previously accepted
let brw = &foo.baz; //~ERROR reference to packed field is unaligned
assert_eq!(*brw, 2);
let foo = Foo2 { bar: 1, baz: 2 };
let brw = &foo.baz; //~WARN reference to packed field is unaligned
//~^ previously accepted
let brw = &foo.baz; //~ERROR reference to packed field is unaligned
assert_eq!(*brw, 2);
}