Skip to content

Commit

Permalink
rustup
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Jul 25, 2022
1 parent b514667 commit 982979e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7fe022f5aa32bbbb33c3a58755729d6667a461a9
2fdbf075cf502431ca9fee6616331b32e34f25de
5 changes: 3 additions & 2 deletions tests/fail/intrinsics/ptr_offset_from_unsigned_neg.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
//@error-pattern: first pointer has smaller offset than second: 0 < 4
// Preparing for a rustc behavior change that'll happen soon: (FIXME remove this after the next submodule bump succeeded)
//@normalize-stderr-test: "`(ptr_offset_from_unsigned)`" -> "$1"
#![feature(ptr_sub_ptr)]

fn main() {
let arr = [0u8; 8];
let ptr1 = arr.as_ptr();
let ptr2 = ptr1.wrapping_add(4);
let _val = unsafe { ptr1.sub_ptr(ptr2) };
let _val = unsafe { ptr1.sub_ptr(ptr2) }; //~ERROR: first pointer has smaller offset than second: 0 < 4
}
13 changes: 4 additions & 9 deletions tests/fail/intrinsics/ptr_offset_from_unsigned_neg.stderr
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
error: Undefined Behavior: ptr_offset_from_unsigned called when first pointer has smaller offset than second: 0 < 4
--> RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
--> $DIR/ptr_offset_from_unsigned_neg.rs:LL:CC
|
LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ptr_offset_from_unsigned called when first pointer has smaller offset than second: 0 < 4
LL | let _val = unsafe { ptr1.sub_ptr(ptr2) };
| ^^^^^^^^^^^^^^^^^^ ptr_offset_from_unsigned called when first pointer has smaller offset than second: 0 < 4
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: backtrace:
= note: inside `std::ptr::const_ptr::<impl *const u8>::sub_ptr` at RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
note: inside `main` at $DIR/ptr_offset_from_unsigned_neg.rs:LL:CC
--> $DIR/ptr_offset_from_unsigned_neg.rs:LL:CC
|
LL | let _val = unsafe { ptr1.sub_ptr(ptr2) };
| ^^^^^^^^^^^^^^^^^^
= note: inside `main` at $DIR/ptr_offset_from_unsigned_neg.rs:LL:CC

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

Expand Down

0 comments on commit 982979e

Please sign in to comment.