1 error[E0080]: evaluation of constant value failed
2 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
4 = note: overflowing in-bounds pointer arithmetic
6 note: inside `ptr::const_ptr::<impl *const u8>::offset`
7 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
8 note: inside `BEFORE_START`
9 --> $DIR/offset_ub.rs:7:46
11 LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) };
12 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14 error[E0080]: evaluation of constant value failed
15 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
17 = note: out-of-bounds pointer arithmetic: allocN has size 1, so pointer to 2 bytes starting at offset 0 is out-of-bounds
19 note: inside `ptr::const_ptr::<impl *const u8>::offset`
20 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
21 note: inside `AFTER_END`
22 --> $DIR/offset_ub.rs:8:43
24 LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) };
25 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
27 error[E0080]: evaluation of constant value failed
28 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
30 = note: out-of-bounds pointer arithmetic: allocN has size 100, so pointer to 101 bytes starting at offset 0 is out-of-bounds
32 note: inside `ptr::const_ptr::<impl *const u8>::offset`
33 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
34 note: inside `AFTER_ARRAY`
35 --> $DIR/offset_ub.rs:9:45
37 LL | pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) };
38 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
40 error[E0080]: evaluation of constant value failed
41 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
43 = note: overflowing in-bounds pointer arithmetic
45 note: inside `ptr::const_ptr::<impl *const u16>::offset`
46 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
47 note: inside `OVERFLOW`
48 --> $DIR/offset_ub.rs:11:43
50 LL | pub const OVERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MAX) };
51 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
53 error[E0080]: evaluation of constant value failed
54 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
56 = note: overflowing in-bounds pointer arithmetic
58 note: inside `ptr::const_ptr::<impl *const u16>::offset`
59 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
60 note: inside `UNDERFLOW`
61 --> $DIR/offset_ub.rs:12:44
63 LL | pub const UNDERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MIN) };
64 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66 error[E0080]: evaluation of constant value failed
67 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
69 = note: overflowing in-bounds pointer arithmetic
71 note: inside `ptr::const_ptr::<impl *const u8>::offset`
72 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
73 note: inside `OVERFLOW_ADDRESS_SPACE`
74 --> $DIR/offset_ub.rs:13:56
76 LL | pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *const u8).offset(2) };
77 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
79 error[E0080]: evaluation of constant value failed
80 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
82 = note: overflowing in-bounds pointer arithmetic
84 note: inside `ptr::const_ptr::<impl *const u8>::offset`
85 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
86 note: inside `UNDERFLOW_ADDRESS_SPACE`
87 --> $DIR/offset_ub.rs:14:57
89 LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) };
90 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
92 error[E0080]: evaluation of constant value failed
93 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
95 = note: out-of-bounds pointer arithmetic: allocN has size 1, so pointer to 2 bytes starting at offset -4 is out-of-bounds
97 note: inside `ptr::const_ptr::<impl *const u8>::offset`
98 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
99 note: inside `NEGATIVE_OFFSET`
100 --> $DIR/offset_ub.rs:15:49
102 LL | pub const NEGATIVE_OFFSET: *const u8 = unsafe { [0u8; 1].as_ptr().wrapping_offset(-2).offset(-2) };
103 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
105 error[E0080]: evaluation of constant value failed
106 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
108 = note: out-of-bounds pointer arithmetic: allocN has size 0, so pointer to 1 byte starting at offset 0 is out-of-bounds
110 note: inside `ptr::const_ptr::<impl *const u8>::offset`
111 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
112 note: inside `ZERO_SIZED_ALLOC`
113 --> $DIR/offset_ub.rs:17:50
115 LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) };
116 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
118 error[E0080]: evaluation of constant value failed
119 --> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
121 = note: out-of-bounds pointer arithmetic: 0x1[noalloc] is a dangling pointer (it has no provenance)
123 note: inside `ptr::mut_ptr::<impl *mut u8>::offset`
124 --> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
125 note: inside `DANGLING`
126 --> $DIR/offset_ub.rs:18:42
128 LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_ptr().offset(4) };
129 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
131 error[E0080]: evaluation of constant value failed
132 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
134 = note: out-of-bounds pointer arithmetic: null pointer is a dangling pointer (it has no provenance)
136 note: inside `ptr::const_ptr::<impl *const u8>::offset`
137 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
138 note: inside `NULL_OFFSET_ZERO`
139 --> $DIR/offset_ub.rs:21:50
141 LL | pub const NULL_OFFSET_ZERO: *const u8 = unsafe { ptr::null::<u8>().offset(0) };
142 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
144 error[E0080]: evaluation of constant value failed
145 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
147 = note: out-of-bounds pointer arithmetic: 0x7f..f[noalloc] is a dangling pointer (it has no provenance)
149 note: inside `ptr::const_ptr::<impl *const u8>::offset`
150 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
151 note: inside `UNDERFLOW_ABS`
152 --> $DIR/offset_ub.rs:24:47
154 LL | pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).offset(isize::MIN) };
155 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
157 error: aborting due to 12 previous errors
159 For more information about this error, try `rustc --explain E0080`.