]> git.lizzy.rs Git - rust.git/commitdiff
rustup
authorRalf Jung <post@ralfj.de>
Mon, 25 Jul 2022 14:35:07 +0000 (10:35 -0400)
committerRalf Jung <post@ralfj.de>
Mon, 25 Jul 2022 14:38:22 +0000 (10:38 -0400)
rust-version
tests/fail/intrinsics/ptr_offset_from_unsigned_neg.rs
tests/fail/intrinsics/ptr_offset_from_unsigned_neg.stderr

index b70ab6fdd46e5d99110ed57722322b787a9f6656..b948bc8b4e6afd5a8f3d633f18841d9eec573140 100644 (file)
@@ -1 +1 @@
-7fe022f5aa32bbbb33c3a58755729d6667a461a9
+2fdbf075cf502431ca9fee6616331b32e34f25de
index d6413faf74bfa97564a6cc813dd309a88e5b0d35..67aa60e785b10671057ff6d13ed64e9655ed02d0 100644 (file)
@@ -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
 }
index bb68f9f5c18c5d9cf2d2e5564e0b28dabf971837..93a05fe8d9e985a1e0e9a45ecdae1a31d9b66568 100644 (file)
@@ -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