1 error[E0080]: evaluation of constant value failed
2 --> $DIR/offset_from_ub.rs:18:27
4 LL | let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) };
5 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ptr_offset_from cannot compute offset of pointers into different allocations.
7 error: any use of this value will cause an error
8 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
10 LL | unsafe { intrinsics::ptr_offset_from(self, origin) }
11 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13 | unable to turn bytes into a pointer
14 | inside `ptr::const_ptr::<impl *const u8>::offset_from` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
15 | inside `NOT_PTR` at $DIR/offset_from_ub.rs:24:14
17 ::: $DIR/offset_from_ub.rs:23:1
19 LL | / pub const NOT_PTR: usize = {
20 LL | | unsafe { (42 as *const u8).offset_from(&5u8) as usize }
24 = note: `#[deny(const_err)]` on by default
25 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
26 = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
28 error[E0080]: evaluation of constant value failed
29 --> $DIR/offset_from_ub.rs:31:14
31 LL | unsafe { ptr_offset_from(field_ptr, base_ptr as *const u16) }
32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: 1_isize cannot be divided by 2_isize without remainder
34 error[E0080]: evaluation of constant value failed
35 --> $DIR/offset_from_ub.rs:37:14
37 LL | unsafe { ptr_offset_from(ptr, ptr) }
38 | ^^^^^^^^^^^^^^^^^^^^^^^^^ null pointer is not a valid pointer for this operation
40 error: any use of this value will cause an error
41 --> $DIR/offset_from_ub.rs:44:14
43 LL | / pub const DIFFERENT_INT: isize = { // offset_from with two different integers: like DIFFERENT_ALLOC
44 LL | | let ptr1 = 8 as *const u8;
45 LL | | let ptr2 = 16 as *const u8;
46 LL | | unsafe { ptr_offset_from(ptr2, ptr1) }
47 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn bytes into a pointer
52 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
53 = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
55 error: aborting due to 5 previous errors
57 For more information about this error, try `rustc --explain E0080`.