]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/ub-ref-ptr.32bit.stderr
Rollup merge of #98496 - BoxyUwU:instancers_bad_equality, r=lcnr
[rust.git] / src / test / ui / consts / const-eval / ub-ref-ptr.32bit.stderr
1 error[E0080]: it is undefined behavior to use this value
2   --> $DIR/ub-ref-ptr.rs:13:1
3    |
4 LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
5    | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
6    |
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: 4, align: 4) {
9                ╾─alloc3──╼                                     │ ╾──╼
10            }
11
12 error[E0080]: it is undefined behavior to use this value
13   --> $DIR/ub-ref-ptr.rs:17:1
14    |
15 LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
16    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1)
17    |
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: 4, align: 4) {
20                ╾─alloc7──╼                                     │ ╾──╼
21            }
22
23 error[E0080]: it is undefined behavior to use this value
24   --> $DIR/ub-ref-ptr.rs:21:1
25    |
26 LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
27    | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference
28    |
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: 4, align: 4) {
31                00 00 00 00                                     │ ....
32            }
33
34 error[E0080]: it is undefined behavior to use this value
35   --> $DIR/ub-ref-ptr.rs:24:1
36    |
37 LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
38    | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box
39    |
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: 4, align: 4) {
42                00 00 00 00                                     │ ....
43            }
44
45 error: any use of this value will cause an error
46   --> $DIR/ub-ref-ptr.rs:31:1
47    |
48 LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
49    | ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
50    |
51    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
52    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
53    = help: this code performed an operation that depends on the underlying bytes representing a pointer
54    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
55    = note: `#[deny(const_err)]` on by default
56
57 error: any use of this value will cause an error
58   --> $DIR/ub-ref-ptr.rs:35:39
59    |
60 LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
61    | ----------------------------------    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
62    |
63    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
64    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
65    = help: this code performed an operation that depends on the underlying bytes representing a pointer
66    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
67
68 error: any use of this value will cause an error
69   --> $DIR/ub-ref-ptr.rs:35:38
70    |
71 LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
72    | ----------------------------------   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
73    |
74    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
75    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
76
77 error: any use of this value will cause an error
78   --> $DIR/ub-ref-ptr.rs:41:86
79    |
80 LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
81    | ------------------------------------------                                           ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
82    |
83    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
84    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
85    = help: this code performed an operation that depends on the underlying bytes representing a pointer
86    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
87
88 error: any use of this value will cause an error
89   --> $DIR/ub-ref-ptr.rs:41:85
90    |
91 LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
92    | ------------------------------------------                                          ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
93    |
94    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
95    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
96
97 error[E0080]: it is undefined behavior to use this value
98   --> $DIR/ub-ref-ptr.rs:47:1
99    |
100 LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
101    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (address 0x539 is unallocated)
102    |
103    = 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.
104    = note: the raw bytes of the constant (size: 4, align: 4) {
105                39 05 00 00                                     │ 9...
106            }
107
108 error[E0080]: it is undefined behavior to use this value
109   --> $DIR/ub-ref-ptr.rs:50:1
110    |
111 LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
112    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (address 0x539 is unallocated)
113    |
114    = 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.
115    = note: the raw bytes of the constant (size: 4, align: 4) {
116                39 05 00 00                                     │ 9...
117            }
118
119 error[E0080]: evaluation of constant value failed
120   --> $DIR/ub-ref-ptr.rs:53:41
121    |
122 LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init };
123    |                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
124
125 error[E0080]: it is undefined behavior to use this value
126   --> $DIR/ub-ref-ptr.rs:57:1
127    |
128 LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
129    | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer
130    |
131    = 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.
132    = note: the raw bytes of the constant (size: 4, align: 4) {
133                00 00 00 00                                     │ ....
134            }
135
136 error[E0080]: evaluation of constant value failed
137   --> $DIR/ub-ref-ptr.rs:59:38
138    |
139 LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init };
140    |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
141
142 error[E0080]: it is undefined behavior to use this value
143   --> $DIR/ub-ref-ptr.rs:62:1
144    |
145 LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
146    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer
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: 4, align: 4) {
150                0d 00 00 00                                     │ ....
151            }
152
153 error[E0080]: it is undefined behavior to use this value
154   --> $DIR/ub-ref-ptr.rs:64:1
155    |
156 LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
157    | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered alloc41, but expected a function pointer
158    |
159    = 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.
160    = note: the raw bytes of the constant (size: 4, align: 4) {
161                ╾─alloc41─╼                                     │ ╾──╼
162            }
163
164 error: aborting due to 16 previous errors
165
166 For more information about this error, try `rustc --explain E0080`.
167 Future incompatibility report: Future breakage diagnostic:
168 error: any use of this value will cause an error
169   --> $DIR/ub-ref-ptr.rs:31:1
170    |
171 LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
172    | ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
173    |
174    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
175    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
176    = help: this code performed an operation that depends on the underlying bytes representing a pointer
177    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
178    = note: `#[deny(const_err)]` on by default
179
180 Future breakage diagnostic:
181 error: any use of this value will cause an error
182   --> $DIR/ub-ref-ptr.rs:35:39
183    |
184 LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
185    | ----------------------------------    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
186    |
187    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
188    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
189    = help: this code performed an operation that depends on the underlying bytes representing a pointer
190    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
191    = note: `#[deny(const_err)]` on by default
192
193 Future breakage diagnostic:
194 error: any use of this value will cause an error
195   --> $DIR/ub-ref-ptr.rs:35:38
196    |
197 LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
198    | ----------------------------------   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
199    |
200    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
201    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
202    = note: `#[deny(const_err)]` on by default
203
204 Future breakage diagnostic:
205 error: any use of this value will cause an error
206   --> $DIR/ub-ref-ptr.rs:41:86
207    |
208 LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
209    | ------------------------------------------                                           ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
210    |
211    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
212    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
213    = help: this code performed an operation that depends on the underlying bytes representing a pointer
214    = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
215    = note: `#[deny(const_err)]` on by default
216
217 Future breakage diagnostic:
218 error: any use of this value will cause an error
219   --> $DIR/ub-ref-ptr.rs:41:85
220    |
221 LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
222    | ------------------------------------------                                          ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
223    |
224    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
225    = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
226    = note: `#[deny(const_err)]` on by default
227