1 error[E0080]: it is undefined behavior to use this value
2 --> $DIR/ub-wide-ptr.rs:38:1
4 LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) };
5 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling reference (going beyond the bounds of its allocation)
7 = 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.
8 = note: the raw bytes of the constant (size: 16, align: 8) {
9 ╾───────allocN────────╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........
12 error[E0080]: it is undefined behavior to use this value
13 --> $DIR/ub-wide-ptr.rs:40:1
15 LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },);
16 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid reference metadata: slice is bigger than largest supported object at .0
18 = 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.
19 = note: the raw bytes of the constant (size: 16, align: 8) {
20 ╾───────allocN───────╼ ff ff ff ff ff ff ff ff │ ╾──────╼........
23 error[E0080]: it is undefined behavior to use this value
24 --> $DIR/ub-wide-ptr.rs:43:1
26 LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) };
27 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in wide pointer
29 = 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.
30 = note: the raw bytes of the constant (size: 16, align: 8) {
31 ╾───────allocN───────╼ ╾───────allocN───────╼ │ ╾──────╼╾──────╼
34 error[E0080]: it is undefined behavior to use this value
35 --> $DIR/ub-wide-ptr.rs:46:1
37 LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) };
38 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in wide pointer
40 = 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.
41 = note: the raw bytes of the constant (size: 16, align: 8) {
42 ╾───────allocN───────╼ ╾───────allocN───────╼ │ ╾──────╼╾──────╼
45 error[E0080]: it is undefined behavior to use this value
46 --> $DIR/ub-wide-ptr.rs:48:1
48 LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) };
49 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid reference metadata: slice is bigger than largest supported object
51 = 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.
52 = note: the raw bytes of the constant (size: 16, align: 8) {
53 ╾───────allocN───────╼ ff ff ff ff ff ff ff ff │ ╾──────╼........
56 error[E0080]: it is undefined behavior to use this value
57 --> $DIR/ub-wide-ptr.rs:52:1
59 LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
60 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized data in `str` at .<deref>
62 = 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.
63 = note: the raw bytes of the constant (size: 16, align: 8) {
64 ╾───────allocN───────╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........
67 error[E0080]: it is undefined behavior to use this value
68 --> $DIR/ub-wide-ptr.rs:55:1
70 LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
71 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized data in `str` at .<deref>.0
73 = 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.
74 = note: the raw bytes of the constant (size: 16, align: 8) {
75 ╾───────allocN───────╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........
78 error[E0080]: it is undefined behavior to use this value
79 --> $DIR/ub-wide-ptr.rs:62:1
81 LL | / const SLICE_LENGTH_UNINIT: &[u8] = unsafe {
83 LL | | let uninit_len = MaybeUninit::<usize> { uninit: () };
84 LL | | mem::transmute((42, uninit_len))
86 | |__^ type validation failed: encountered uninitialized reference
88 = 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.
89 = note: the raw bytes of the constant (size: 16, align: 8) {
90 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
93 error[E0080]: it is undefined behavior to use this value
94 --> $DIR/ub-wide-ptr.rs:68:1
96 LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) };
97 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling reference (going beyond the bounds of its allocation)
99 = 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.
100 = note: the raw bytes of the constant (size: 16, align: 8) {
101 ╾───────allocN───────╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........
104 error[E0080]: it is undefined behavior to use this value
105 --> $DIR/ub-wide-ptr.rs:71:1
107 LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) };
108 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in wide pointer
110 = 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.
111 = note: the raw bytes of the constant (size: 16, align: 8) {
112 ╾───────allocN───────╼ ╾───────allocN───────╼ │ ╾──────╼╾──────╼
115 error[E0080]: it is undefined behavior to use this value
116 --> $DIR/ub-wide-ptr.rs:74:1
118 LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) };
119 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling box (going beyond the bounds of its allocation)
121 = 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.
122 = note: the raw bytes of the constant (size: 16, align: 8) {
123 ╾───────allocN───────╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........
126 error[E0080]: it is undefined behavior to use this value
127 --> $DIR/ub-wide-ptr.rs:77:1
129 LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) };
130 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in wide pointer
132 = 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.
133 = note: the raw bytes of the constant (size: 16, align: 8) {
134 ╾───────allocN───────╼ ╾───────allocN───────╼ │ ╾──────╼╾──────╼
137 error[E0080]: it is undefined behavior to use this value
138 --> $DIR/ub-wide-ptr.rs:81:1
140 LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
141 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x03 at .<deref>[0], but expected a boolean
143 = 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.
144 = note: the raw bytes of the constant (size: 8, align: 8) {
145 ╾───────allocN───────╼ │ ╾──────╼
148 error[E0080]: it is undefined behavior to use this value
149 --> $DIR/ub-wide-ptr.rs:87:1
151 LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
152 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x03 at .<deref>.0, but expected a boolean
154 = 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.
155 = note: the raw bytes of the constant (size: 8, align: 8) {
156 ╾───────allocN───────╼ │ ╾──────╼
159 error[E0080]: it is undefined behavior to use this value
160 --> $DIR/ub-wide-ptr.rs:90:1
162 LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
163 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x03 at .<deref>.1[0], but expected a boolean
165 = 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.
166 = note: the raw bytes of the constant (size: 8, align: 8) {
167 ╾───────allocN───────╼ │ ╾──────╼
170 error[E0080]: it is undefined behavior to use this value
171 --> $DIR/ub-wide-ptr.rs:97:1
173 LL | / const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe {
175 LL | | let uninit_len = MaybeUninit::<usize> { uninit: () };
176 LL | | mem::transmute((42, uninit_len))
178 | |__^ type validation failed: encountered uninitialized raw pointer
180 = 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.
181 = note: the raw bytes of the constant (size: 16, align: 8) {
182 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
185 error[E0080]: it is undefined behavior to use this value
186 --> $DIR/ub-wide-ptr.rs:105:1
188 LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) };
189 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered too small vtable at .0
191 = 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.
192 = note: the raw bytes of the constant (size: 16, align: 8) {
193 ╾──────allocN───────╼ ╾──────allocN───────╼ │ ╾──────╼╾──────╼
196 error[E0080]: it is undefined behavior to use this value
197 --> $DIR/ub-wide-ptr.rs:108:1
199 LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) };
200 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered too small vtable at .0
202 = 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.
203 = note: the raw bytes of the constant (size: 16, align: 8) {
204 ╾──────allocN───────╼ ╾──────allocN───────╼ │ ╾──────╼╾──────╼
207 error[E0080]: it is undefined behavior to use this value
208 --> $DIR/ub-wide-ptr.rs:111:1
210 LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) };
211 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling vtable pointer in wide pointer at .0
213 = 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.
214 = note: the raw bytes of the constant (size: 16, align: 8) {
215 ╾──────allocN───────╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........
218 error[E0080]: it is undefined behavior to use this value
219 --> $DIR/ub-wide-ptr.rs:113:1
221 LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) };
222 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered unaligned vtable pointer in wide pointer
224 = 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.
225 = note: the raw bytes of the constant (size: 16, align: 8) {
226 ╾──────allocN───────╼ ╾──────allocN───────╼ │ ╾──────╼╾──────╼
229 error[E0080]: it is undefined behavior to use this value
230 --> $DIR/ub-wide-ptr.rs:115:1
232 LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) };
233 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop function pointer in vtable (not pointing to a function)
235 = 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.
236 = note: the raw bytes of the constant (size: 16, align: 8) {
237 ╾──────allocN───────╼ ╾──────allocN───────╼ │ ╾──────╼╾──────╼
240 error[E0080]: it is undefined behavior to use this value
241 --> $DIR/ub-wide-ptr.rs:117:1
243 LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) };
244 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop function pointer in vtable (not pointing to a function)
246 = 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.
247 = note: the raw bytes of the constant (size: 16, align: 8) {
248 ╾──────allocN───────╼ ╾──────allocN───────╼ │ ╾──────╼╾──────╼
251 error[E0080]: it is undefined behavior to use this value
252 --> $DIR/ub-wide-ptr.rs:119:1
254 LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) };
255 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop function pointer in vtable (not pointing to a function) at .0
257 = 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.
258 = note: the raw bytes of the constant (size: 16, align: 8) {
259 ╾──────allocN───────╼ ╾──────allocN───────╼ │ ╾──────╼╾──────╼
262 error[E0080]: it is undefined behavior to use this value
263 --> $DIR/ub-wide-ptr.rs:123:1
265 LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) };
266 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x03 at .<deref>.<dyn-downcast>, but expected a boolean
268 = 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.
269 = note: the raw bytes of the constant (size: 16, align: 8) {
270 ╾──────allocN───────╼ ╾──────allocN───────╼ │ ╾──────╼╾──────╼
273 error[E0080]: it is undefined behavior to use this value
274 --> $DIR/ub-wide-ptr.rs:127:1
276 LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
277 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling vtable pointer in wide pointer
279 = 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.
280 = note: the raw bytes of the constant (size: 16, align: 8) {
281 ╾──────allocN───────╼ 00 00 00 00 00 00 00 00 │ ╾──────╼........
284 error[E0080]: it is undefined behavior to use this value
285 --> $DIR/ub-wide-ptr.rs:129:1
287 LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
288 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered too small vtable
290 = 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.
291 = note: the raw bytes of the constant (size: 16, align: 8) {
292 ╾──────allocN───────╼ ╾──────allocN───────╼ │ ╾──────╼╾──────╼
295 error[E0080]: could not evaluate static initializer
296 --> $DIR/ub-wide-ptr.rs:135:5
298 LL | mem::transmute::<_, &dyn Trait>((&92u8, 0usize))
299 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ null pointer is not a valid pointer for this operation
301 error[E0080]: could not evaluate static initializer
302 --> $DIR/ub-wide-ptr.rs:139:5
304 LL | mem::transmute::<_, &dyn Trait>((&92u8, &3u64))
305 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: pointer must be in-bounds at offset N, but is outside bounds of allocN which has size N
307 error: aborting due to 28 previous errors
309 For more information about this error, try `rustc --explain E0080`.