Skip to content

Commit 16da293

Browse files
authored
Merge pull request #4176 from rust-lang/rustup-2025-02-04
Automatic Rustup
2 parents e4280d9 + d3f9e19 commit 16da293

8 files changed

+47
-4
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
613bdd49978298648ed05ace086bd1ecad54b44a
1+
affdb59607566c1615c829eea9e7b27a093994ec
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn main() {
2+
unsafe {
3+
(&1_u8 as *const u8).offset_from(&2_u8); //~ERROR: not both derived from the same allocation
4+
}
5+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: Undefined Behavior: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation
2+
--> tests/fail/intrinsics/ptr_offset_from_different_allocs.rs:LL:CC
3+
|
4+
LL | (&1_u8 as *const u8).offset_from(&2_u8);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers that are not both derived from the same allocation
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `main` at tests/fail/intrinsics/ptr_offset_from_different_allocs.rs:LL:CC
11+
12+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
13+
14+
error: aborting due to 1 previous error
15+

tests/fail/intrinsics/ptr_offset_from_different_ints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ fn main() {
1515
let _ = p1.byte_offset_from(p1);
1616

1717
// UB because different pointers.
18-
let _ = p1.byte_offset_from(p2); //~ERROR: no provenance
18+
let _ = p1.byte_offset_from(p2); //~ERROR: not both derived from the same allocation
1919
}
2020
}

tests/fail/intrinsics/ptr_offset_from_different_ints.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: Undefined Behavior: out-of-bounds `offset_from` origin: expected a pointer to the end of 1 byte of memory, but got 0xb[noalloc] which is a dangling pointer (it has no provenance)
1+
error: Undefined Behavior: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation
22
--> tests/fail/intrinsics/ptr_offset_from_different_ints.rs:LL:CC
33
|
44
LL | let _ = p1.byte_offset_from(p2);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from` origin: expected a pointer to the end of 1 byte of memory, but got 0xb[noalloc] which is a dangling pointer (it has no provenance)
5+
| ^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers that are not both derived from the same allocation
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
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn main() {
2+
let mem = [0u8; 1];
3+
let ptr = mem.as_ptr();
4+
unsafe {
5+
ptr.wrapping_add(4).offset_from(ptr); //~ERROR: the memory range between them is not in-bounds of an allocation
6+
}
7+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: Undefined Behavior: `ptr_offset_from` called on two different pointers where the memory range between them is not in-bounds of an allocation
2+
--> tests/fail/intrinsics/ptr_offset_from_oob.rs:LL:CC
3+
|
4+
LL | ptr.wrapping_add(4).offset_from(ptr);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers where the memory range between them is not in-bounds of an allocation
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `main` at tests/fail/intrinsics/ptr_offset_from_oob.rs:LL:CC
11+
12+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
13+
14+
error: aborting due to 1 previous error
15+

tests/x86_64-unknown-kernel.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"vendor": "unknown",
1111
"linker": "rust-lld",
1212
"linker-flavor": "gnu-lld",
13+
"rustc-abi": "x86-softfloat",
1314
"features": "-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2,+soft-float",
1415
"dynamic-linking": false,
1516
"executables": true,

0 commit comments

Comments
 (0)