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"
3
4
4
5
#[ repr( align( 256 ) ) ]
5
6
#[ derive( Debug ) ]
@@ -19,6 +20,6 @@ fn main() {
19
20
( & mut ptr as * mut _ as * mut * const u8 ) . write ( & buf as * const _ as * const u8 ) ;
20
21
}
21
22
// 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
23
24
}
24
25
}
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)
2
2
--> $DIR/dyn_alignment.rs:LL:CC
3
3
|
4
4
LL | 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)
6
6
|
7
7
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8
8
= 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