File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed
tests/fail/unaligned_pointers Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change 1- // should find the bug even without validation and stacked borrows, but gets masked by optimizations
2- //@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows -Zmir-opt-level=0 -Cdebug-assertions=no
1+ // should find the bug even without, but gets masked by optimizations
2+ //@compile-flags: -Zmiri-disable-stacked-borrows -Zmir-opt-level=0 -Cdebug-assertions=no
3+ //@normalize-stderr-test: "but found [0-9]+" -> "but found $$ALIGN"
34
45#[ repr( align( 256 ) ) ]
56#[ derive( Debug ) ]
@@ -19,6 +20,6 @@ fn main() {
1920 ( & mut ptr as * mut _ as * mut * const u8 ) . write ( & buf as * const _ as * const u8 ) ;
2021 }
2122 // Re-borrow that. This should be UB.
22- let _ptr = & * ptr; //~ERROR: alignment 256 is required
23+ let _ptr = & * ptr; //~ERROR: required 256 byte alignment
2324 }
2425}
Original file line number Diff line number Diff line change 1- error: Undefined Behavior: accessing memory with alignment ALIGN, but alignment ALIGN is required
1+ error: Undefined Behavior: constructing invalid value: encountered an unaligned reference (required 256 byte alignment but found $ALIGN)
22 --> $DIR/dyn_alignment.rs:LL:CC
33 |
44LL | let _ptr = &*ptr;
5- | ^^^^^ accessing memory with alignment ALIGN, but alignment ALIGN is required
5+ | ^^^^^ constructing invalid value: encountered an unaligned reference (required 256 byte alignment but found $ALIGN)
66 |
77 = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88 = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
You can’t perform that action at this time.
0 commit comments