forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#99692 - RalfJung:too-far, r=oli-obk
interpret, ptr_offset_from: refactor and test too-far-apart check We didn't have any tests for the "too far apart" message, and indeed that check mostly relied on the in-bounds check and was otherwise probably not entirely correct... so I rewrote that check, and it is before the in-bounds check so we can test it separately.
- Loading branch information
Showing
6 changed files
with
152 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,117 @@ | ||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/offset_from_ub.rs:17:27 | ||
--> $DIR/offset_from_ub.rs:18:27 | ||
| | ||
LL | let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ptr_offset_from called on pointers into different allocations | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on pointers into different allocations | ||
|
||
error[E0080]: evaluation of constant value failed | ||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | ||
| | ||
LL | unsafe { intrinsics::ptr_offset_from(self, origin) } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| ptr_offset_from called on pointers into different allocations | ||
| `ptr_offset_from` called on pointers into different allocations | ||
| inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | ||
| | ||
::: $DIR/offset_from_ub.rs:23:14 | ||
::: $DIR/offset_from_ub.rs:24:14 | ||
| | ||
LL | unsafe { (42 as *const u8).offset_from(&5u8) as usize } | ||
| ----------------------------------- inside `NOT_PTR` at $DIR/offset_from_ub.rs:23:14 | ||
| ----------------------------------- inside `NOT_PTR` at $DIR/offset_from_ub.rs:24:14 | ||
|
||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/offset_from_ub.rs:30:14 | ||
--> $DIR/offset_from_ub.rs:31:14 | ||
| | ||
LL | unsafe { ptr_offset_from(field_ptr, base_ptr as *const u16) } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: 1_isize cannot be divided by 2_isize without remainder | ||
|
||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/offset_from_ub.rs:36:14 | ||
--> $DIR/offset_from_ub.rs:37:14 | ||
| | ||
LL | unsafe { ptr_offset_from(ptr, ptr) } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance) | ||
|
||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/offset_from_ub.rs:43:14 | ||
--> $DIR/offset_from_ub.rs:44:14 | ||
| | ||
LL | unsafe { ptr_offset_from(ptr2, ptr1) } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: 0x8[noalloc] is a dangling pointer (it has no provenance) | ||
|
||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/offset_from_ub.rs:52:14 | ||
--> $DIR/offset_from_ub.rs:53:14 | ||
| | ||
LL | unsafe { ptr_offset_from(end_ptr, start_ptr) } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc18 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds | ||
|
||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/offset_from_ub.rs:61:14 | ||
--> $DIR/offset_from_ub.rs:62:14 | ||
| | ||
LL | unsafe { ptr_offset_from(start_ptr, end_ptr) } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc21 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds | ||
|
||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/offset_from_ub.rs:69:14 | ||
--> $DIR/offset_from_ub.rs:70:14 | ||
| | ||
LL | unsafe { ptr_offset_from(end_ptr, end_ptr) } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc24 has size 4, so pointer at offset 10 is out-of-bounds | ||
|
||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/offset_from_ub.rs:78:27 | ||
--> $DIR/offset_from_ub.rs:79:14 | ||
| | ||
LL | let offset = unsafe { ptr_offset_from_unsigned(field_ptr, base_ptr) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ptr_offset_from_unsigned called on pointers into different allocations | ||
LL | unsafe { ptr_offset_from_unsigned(field_ptr, base_ptr) } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on pointers into different allocations | ||
|
||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/offset_from_ub.rs:86:14 | ||
| | ||
LL | unsafe { ptr_offset_from(ptr2, ptr1) } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called when first pointer is too far ahead of second | ||
|
||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/offset_from_ub.rs:92:14 | ||
| | ||
LL | unsafe { ptr_offset_from(ptr1, ptr2) } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called when first pointer is too far before second | ||
|
||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/offset_from_ub.rs:99:14 | ||
| | ||
LL | unsafe { ptr_offset_from_unsigned(p, p.add(2) ) } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ptr_offset_from_unsigned called when first pointer has smaller offset than second: 0 < 8 | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called when first pointer has smaller offset than second: 0 < 8 | ||
|
||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/offset_from_ub.rs:106:14 | ||
| | ||
LL | unsafe { ptr_offset_from_unsigned(ptr2, ptr1) } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called when first pointer is too far ahead of second | ||
|
||
error[E0080]: evaluation of constant value failed | ||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | ||
| | ||
LL | unsafe { intrinsics::ptr_offset_from(self, origin) } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance) | ||
| inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | ||
| | ||
::: $DIR/offset_from_ub.rs:115:14 | ||
| | ||
LL | unsafe { ptr2.offset_from(ptr1) } | ||
| ---------------------- inside `OFFSET_VERY_FAR1` at $DIR/offset_from_ub.rs:115:14 | ||
|
||
error[E0080]: evaluation of constant value failed | ||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | ||
| | ||
LL | unsafe { intrinsics::ptr_offset_from(self, origin) } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance) | ||
| inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | ||
| | ||
::: $DIR/offset_from_ub.rs:121:14 | ||
| | ||
LL | unsafe { ptr1.offset_from(ptr2.wrapping_offset(1)) } | ||
| ----------------------------------------- inside `OFFSET_VERY_FAR2` at $DIR/offset_from_ub.rs:121:14 | ||
|
||
error: aborting due to 10 previous errors | ||
error: aborting due to 15 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0080`. |