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` called on pointers into different allocations
7 error[E0080]: evaluation of constant value failed
8 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
10 = note: `ptr_offset_from` called on pointers into different allocations
12 note: inside `ptr::const_ptr::<impl *const u8>::offset_from`
13 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
14 note: inside `NOT_PTR`
15 --> $DIR/offset_from_ub.rs:24:14
17 LL | unsafe { (42 as *const u8).offset_from(&5u8) as usize }
18 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20 error[E0080]: evaluation of constant value failed
21 --> $DIR/offset_from_ub.rs:31:14
23 LL | unsafe { ptr_offset_from(field_ptr, base_ptr as *const u16) }
24 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: 1_isize cannot be divided by 2_isize without remainder
26 error[E0080]: evaluation of constant value failed
27 --> $DIR/offset_from_ub.rs:37:14
29 LL | unsafe { ptr_offset_from(ptr, ptr) }
30 | ^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance)
32 error[E0080]: evaluation of constant value failed
33 --> $DIR/offset_from_ub.rs:44:14
35 LL | unsafe { ptr_offset_from(ptr2, ptr1) }
36 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: 0x8[noalloc] is a dangling pointer (it has no provenance)
38 error[E0080]: evaluation of constant value failed
39 --> $DIR/offset_from_ub.rs:53:14
41 LL | unsafe { ptr_offset_from(end_ptr, start_ptr) }
42 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc18 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds
44 error[E0080]: evaluation of constant value failed
45 --> $DIR/offset_from_ub.rs:62:14
47 LL | unsafe { ptr_offset_from(start_ptr, end_ptr) }
48 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc21 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds
50 error[E0080]: evaluation of constant value failed
51 --> $DIR/offset_from_ub.rs:70:14
53 LL | unsafe { ptr_offset_from(end_ptr, end_ptr) }
54 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc24 has size 4, so pointer at offset 10 is out-of-bounds
56 error[E0080]: evaluation of constant value failed
57 --> $DIR/offset_from_ub.rs:79:14
59 LL | unsafe { ptr_offset_from_unsigned(field_ptr, base_ptr) }
60 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on pointers into different allocations
62 error[E0080]: evaluation of constant value failed
63 --> $DIR/offset_from_ub.rs:86:14
65 LL | unsafe { ptr_offset_from(ptr2, ptr1) }
66 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called when first pointer is too far ahead of second
68 error[E0080]: evaluation of constant value failed
69 --> $DIR/offset_from_ub.rs:92:14
71 LL | unsafe { ptr_offset_from(ptr1, ptr2) }
72 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called when first pointer is too far before second
74 error[E0080]: evaluation of constant value failed
75 --> $DIR/offset_from_ub.rs:99:14
77 LL | unsafe { ptr_offset_from_unsigned(p, p.add(2) ) }
78 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called when first pointer has smaller offset than second: 0 < 8
80 error[E0080]: evaluation of constant value failed
81 --> $DIR/offset_from_ub.rs:106:14
83 LL | unsafe { ptr_offset_from_unsigned(ptr2, ptr1) }
84 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called when first pointer is too far ahead of second
86 error[E0080]: evaluation of constant value failed
87 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
89 = note: out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance)
91 note: inside `ptr::const_ptr::<impl *const u8>::offset_from`
92 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
93 note: inside `OFFSET_VERY_FAR1`
94 --> $DIR/offset_from_ub.rs:115:14
96 LL | unsafe { ptr2.offset_from(ptr1) }
97 | ^^^^^^^^^^^^^^^^^^^^^^
99 error[E0080]: evaluation of constant value failed
100 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
102 = note: out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance)
104 note: inside `ptr::const_ptr::<impl *const u8>::offset_from`
105 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
106 note: inside `OFFSET_VERY_FAR2`
107 --> $DIR/offset_from_ub.rs:121:14
109 LL | unsafe { ptr1.offset_from(ptr2.wrapping_offset(1)) }
110 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
112 error: aborting due to 15 previous errors
114 For more information about this error, try `rustc --explain E0080`.