]> git.proxmox.com Git - rustc.git/blob - tests/ui/const-ptr/forbidden_slices.stderr
New upstream version 1.71.1+dfsg1
[rustc.git] / tests / ui / const-ptr / forbidden_slices.stderr
1 error[E0080]: could not evaluate static initializer
2 --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
3 |
4 = note: dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance)
5 |
6 note: inside `std::slice::from_raw_parts::<'_, u32>`
7 --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
8 note: inside `S0`
9 --> $DIR/forbidden_slices.rs:19:34
10 |
11 LL | pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) };
12 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13
14 error[E0080]: could not evaluate static initializer
15 --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
16 |
17 = note: dereferencing pointer failed: null pointer is a dangling pointer (it has no provenance)
18 |
19 note: inside `std::slice::from_raw_parts::<'_, ()>`
20 --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
21 note: inside `S1`
22 --> $DIR/forbidden_slices.rs:20:33
23 |
24 LL | pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) };
25 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26
27 error[E0080]: could not evaluate static initializer
28 --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
29 |
30 = note: dereferencing pointer failed: allocN has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
31 |
32 note: inside `std::slice::from_raw_parts::<'_, u32>`
33 --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
34 note: inside `S2`
35 --> $DIR/forbidden_slices.rs:23:34
36 |
37 LL | pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) };
38 | ^^^^^^^^^^^^^^^^^^^^^^
39
40 error[E0080]: it is undefined behavior to use this value
41 --> $DIR/forbidden_slices.rs:26:1
42 |
43 LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) };
44 | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized bytes
45 |
46 = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
47 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
48 HEX_DUMP
49 }
50
51 error[E0080]: it is undefined behavior to use this value
52 --> $DIR/forbidden_slices.rs:28:1
53 |
54 LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size_of::<&u32>()) };
55 | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
56 |
57 = help: this code performed an operation that depends on the underlying bytes representing a pointer
58 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
59 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
60 HEX_DUMP
61 }
62
63 error[E0080]: it is undefined behavior to use this value
64 --> $DIR/forbidden_slices.rs:30:1
65 |
66 LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) };
67 | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean
68 |
69 = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
70 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
71 HEX_DUMP
72 }
73
74 error[E0080]: it is undefined behavior to use this value
75 --> $DIR/forbidden_slices.rs:33:1
76 |
77 LL | pub static S7: &[u16] = unsafe {
78 | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[1]: encountered uninitialized bytes
79 |
80 = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
81 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
82 HEX_DUMP
83 }
84
85 error[E0080]: could not evaluate static initializer
86 --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
87 |
88 = note: dereferencing pointer failed: allocN has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds
89 |
90 note: inside `std::slice::from_raw_parts::<'_, u64>`
91 --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
92 note: inside `S8`
93 --> $DIR/forbidden_slices.rs:44:5
94 |
95 LL | from_raw_parts(ptr, 1)
96 | ^^^^^^^^^^^^^^^^^^^^^^
97
98 error[E0080]: could not evaluate static initializer
99 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
100 |
101 = note: out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance)
102 |
103 note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr`
104 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
105 note: inside `from_ptr_range::<'_, u32>`
106 --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
107 note: inside `R0`
108 --> $DIR/forbidden_slices.rs:47:34
109 |
110 LL | pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
111 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
112
113 error[E0080]: could not evaluate static initializer
114 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
115 |
116 = note: the evaluated program panicked at 'assertion failed: 0 < pointee_size && pointee_size <= isize::MAX as usize', $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
117 |
118 note: inside `ptr::const_ptr::<impl *const ()>::sub_ptr`
119 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
120 note: inside `from_ptr_range::<'_, ()>`
121 --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
122 note: inside `R1`
123 --> $DIR/forbidden_slices.rs:48:33
124 |
125 LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
126 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
127 = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
128
129 error[E0080]: could not evaluate static initializer
130 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
131 |
132 = note: out-of-bounds pointer arithmetic: allocN has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
133 |
134 note: inside `ptr::const_ptr::<impl *const u32>::add`
135 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
136 note: inside `R2`
137 --> $DIR/forbidden_slices.rs:51:25
138 |
139 LL | from_ptr_range(ptr..ptr.add(2))
140 | ^^^^^^^^^^
141
142 error[E0080]: it is undefined behavior to use this value
143 --> $DIR/forbidden_slices.rs:53:1
144 |
145 LL | pub static R4: &[u8] = unsafe {
146 | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized bytes
147 |
148 = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
149 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
150 HEX_DUMP
151 }
152
153 error[E0080]: it is undefined behavior to use this value
154 --> $DIR/forbidden_slices.rs:58:1
155 |
156 LL | pub static R5: &[u8] = unsafe {
157 | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
158 |
159 = help: this code performed an operation that depends on the underlying bytes representing a pointer
160 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
161 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
162 HEX_DUMP
163 }
164
165 error[E0080]: it is undefined behavior to use this value
166 --> $DIR/forbidden_slices.rs:63:1
167 |
168 LL | pub static R6: &[bool] = unsafe {
169 | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean
170 |
171 = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
172 = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
173 HEX_DUMP
174 }
175
176 error[E0080]: could not evaluate static initializer
177 --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
178 |
179 = note: accessing memory with alignment 1, but alignment 2 is required
180 |
181 note: inside `std::slice::from_raw_parts::<'_, u16>`
182 --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
183 note: inside `from_ptr_range::<'_, u16>`
184 --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
185 note: inside `R7`
186 --> $DIR/forbidden_slices.rs:70:5
187 |
188 LL | from_ptr_range(ptr..ptr.add(4))
189 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
190
191 error[E0080]: could not evaluate static initializer
192 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
193 |
194 = note: out-of-bounds pointer arithmetic: allocN has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds
195 |
196 note: inside `ptr::const_ptr::<impl *const u64>::add`
197 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
198 note: inside `R8`
199 --> $DIR/forbidden_slices.rs:74:25
200 |
201 LL | from_ptr_range(ptr..ptr.add(1))
202 | ^^^^^^^^^^
203
204 error[E0080]: could not evaluate static initializer
205 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
206 |
207 = note: `ptr_offset_from_unsigned` called on pointers into different allocations
208 |
209 note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr`
210 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
211 note: inside `from_ptr_range::<'_, u32>`
212 --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
213 note: inside `R9`
214 --> $DIR/forbidden_slices.rs:79:34
215 |
216 LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) };
217 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
218
219 error[E0080]: could not evaluate static initializer
220 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
221 |
222 = note: `ptr_offset_from_unsigned` called on pointers into different allocations
223 |
224 note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr`
225 --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
226 note: inside `from_ptr_range::<'_, u32>`
227 --> $SRC_DIR/core/src/slice/raw.rs:LL:COL
228 note: inside `R10`
229 --> $DIR/forbidden_slices.rs:80:35
230 |
231 LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) };
232 | ^^^^^^^^^^^^^^^^^^^^^^^^
233
234 error: aborting due to 18 previous errors
235
236 For more information about this error, try `rustc --explain E0080`.