File tree Expand file tree Collapse file tree 3 files changed +8
-12
lines changed Expand file tree Collapse file tree 3 files changed +8
-12
lines changed Original file line number Diff line number Diff line change 1- 7fe022f5aa32bbbb33c3a58755729d6667a461a9
1+ 2fdbf075cf502431ca9fee6616331b32e34f25de
Original file line number Diff line number Diff line change 1- //@error-pattern: first pointer has smaller offset than second: 0 < 4
1+ // Preparing for a rustc behavior change that'll happen soon: (FIXME remove this after the next submodule bump succeeded)
2+ //@normalize-stderr-test: "`(ptr_offset_from_unsigned)`" -> "$1"
23#![ feature( ptr_sub_ptr) ]
34
45fn main ( ) {
56 let arr = [ 0u8 ; 8 ] ;
67 let ptr1 = arr. as_ptr ( ) ;
78 let ptr2 = ptr1. wrapping_add ( 4 ) ;
8- let _val = unsafe { ptr1. sub_ptr ( ptr2) } ;
9+ let _val = unsafe { ptr1. sub_ptr ( ptr2) } ; //~ERROR: first pointer has smaller offset than second: 0 < 4
910}
Original file line number Diff line number Diff line change 11error: Undefined Behavior: ptr_offset_from_unsigned called when first pointer has smaller offset than second: 0 < 4
2- --> RUSTLIB/core/src/ptr/const_ptr .rs:LL:CC
2+ --> $DIR/ptr_offset_from_unsigned_neg .rs:LL:CC
33 |
4- LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin ) }
5- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ptr_offset_from_unsigned called when first pointer has smaller offset than second: 0 < 4
4+ LL | let _val = unsafe { ptr1.sub_ptr(ptr2 ) };
5+ | ^^^^^^^^^^^^^^^^^^ ptr_offset_from_unsigned called when first pointer has smaller offset than second: 0 < 4
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
99 = note: backtrace:
10- = note: inside `std::ptr::const_ptr::<impl *const u8>::sub_ptr` at RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
11- note: inside `main` at $DIR/ptr_offset_from_unsigned_neg.rs:LL:CC
12- --> $DIR/ptr_offset_from_unsigned_neg.rs:LL:CC
13- |
14- LL | let _val = unsafe { ptr1.sub_ptr(ptr2) };
15- | ^^^^^^^^^^^^^^^^^^
10+ = note: inside `main` at $DIR/ptr_offset_from_unsigned_neg.rs:LL:CC
1611
1712note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1813
You can’t perform that action at this time.
0 commit comments