File tree 3 files changed +8
-12
lines changed
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"
2
3
#![ feature( ptr_sub_ptr) ]
3
4
4
5
fn main ( ) {
5
6
let arr = [ 0u8 ; 8 ] ;
6
7
let ptr1 = arr. as_ptr ( ) ;
7
8
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
9
10
}
Original file line number Diff line number Diff line change 1
1
error: 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
3
3
|
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
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
9
9
= 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
16
11
17
12
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
18
13
You can’t perform that action at this time.
0 commit comments