@@ -102,13 +102,27 @@ error[E0080]: evaluation of constant value failed
102
102
LL | unsafe { intrinsics::offset(self, count) }
103
103
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
104
104
| |
105
- | pointer arithmetic failed: allocN has size 0 , so pointer to 1 bytes starting at offset 0 is out-of-bounds
105
+ | pointer arithmetic failed: allocN has size 1 , so pointer to 2 bytes starting at offset -4 is out-of-bounds
106
106
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
107
107
|
108
- ::: $DIR/offset_ub.rs:17:50
108
+ ::: $DIR/offset_ub.rs:16:49
109
+ |
110
+ LL | pub const NEGATIVE_OFFSET: *const u8 = unsafe { [0u8; 1].as_ptr().wrapping_offset(-2).offset(-2) };
111
+ | ------------------------------------------------ inside `NEGATIVE_OFFSET` at $DIR/offset_ub.rs:16:49
112
+
113
+ error[E0080]: evaluation of constant value failed
114
+ --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
115
+ |
116
+ LL | unsafe { intrinsics::offset(self, count) }
117
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
118
+ | |
119
+ | pointer arithmetic failed: allocN has size 0, so pointer to 1 byte starting at offset 0 is out-of-bounds
120
+ | inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
121
+ |
122
+ ::: $DIR/offset_ub.rs:18:50
109
123
|
110
124
LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) };
111
- | --------------------------- inside `ZERO_SIZED_ALLOC` at $DIR/offset_ub.rs:17 :50
125
+ | --------------------------- inside `ZERO_SIZED_ALLOC` at $DIR/offset_ub.rs:18 :50
112
126
113
127
error[E0080]: evaluation of constant value failed
114
128
--> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
@@ -119,10 +133,10 @@ LL | unsafe { intrinsics::offset(self, count) as *mut T }
119
133
| 0x1 is not a valid pointer
120
134
| inside `ptr::mut_ptr::<impl *mut u8>::offset` at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
121
135
|
122
- ::: $DIR/offset_ub.rs:18 :42
136
+ ::: $DIR/offset_ub.rs:19 :42
123
137
|
124
138
LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_ptr().offset(4) };
125
- | ------------------------------------------------- inside `DANGLING` at $DIR/offset_ub.rs:18 :42
139
+ | ------------------------------------------------- inside `DANGLING` at $DIR/offset_ub.rs:19 :42
126
140
127
141
error[E0080]: evaluation of constant value failed
128
142
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@@ -133,10 +147,10 @@ LL | unsafe { intrinsics::offset(self, count) }
133
147
| pointer arithmetic failed: 0x0 is not a valid pointer
134
148
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
135
149
|
136
- ::: $DIR/offset_ub.rs:21 :50
150
+ ::: $DIR/offset_ub.rs:22 :50
137
151
|
138
152
LL | pub const NULL_OFFSET_ZERO: *const u8 = unsafe { ptr::null::<u8>().offset(0) };
139
- | --------------------------- inside `NULL_OFFSET_ZERO` at $DIR/offset_ub.rs:21 :50
153
+ | --------------------------- inside `NULL_OFFSET_ZERO` at $DIR/offset_ub.rs:22 :50
140
154
141
155
error[E0080]: evaluation of constant value failed
142
156
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@@ -147,11 +161,11 @@ LL | unsafe { intrinsics::offset(self, count) }
147
161
| 0x7f..f is not a valid pointer
148
162
| inside `ptr::const_ptr::<impl *const u8>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
149
163
|
150
- ::: $DIR/offset_ub.rs:24 :47
164
+ ::: $DIR/offset_ub.rs:25 :47
151
165
|
152
166
LL | pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).offset(isize::MIN) };
153
- | -------------------------------------------- inside `UNDERFLOW_ABS` at $DIR/offset_ub.rs:24 :47
167
+ | -------------------------------------------- inside `UNDERFLOW_ABS` at $DIR/offset_ub.rs:25 :47
154
168
155
- error: aborting due to 11 previous errors
169
+ error: aborting due to 12 previous errors
156
170
157
171
For more information about this error, try `rustc --explain E0080`.
0 commit comments