]> git.proxmox.com Git - rustc.git/blob - src/test/ui/consts/const-eval/ub-ref-ptr.32bit.stderr
New upstream version 1.63.0+dfsg1
[rustc.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 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: 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 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: 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 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: 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 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: 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[E0080]: it is undefined behavior to use this value
46 --> $DIR/ub-ref-ptr.rs:31:1
47 |
48 LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
49 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc15, but expected plain (non-pointer) bytes
50 |
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: 4, align: 4) {
53 ╾─alloc15─╼ │ ╾──╼
54 }
55
56 error[E0080]: it is undefined behavior to use this value
57 --> $DIR/ub-ref-ptr.rs:34:1
58 |
59 LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
60 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .<deref>: encountered a pointer, but expected plain (non-pointer) bytes
61 |
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: 4, align: 4) {
64 ╾─alloc21─╼ │ ╾──╼
65 }
66
67 error[E0080]: it is undefined behavior to use this value
68 --> $DIR/ub-ref-ptr.rs:37:1
69 |
70 LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
71 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .<deref>: encountered a pointer, but expected plain (non-pointer) bytes
72 |
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: 4, align: 4) {
75 ╾─alloc26─╼ │ ╾──╼
76 }
77
78 error[E0080]: it is undefined behavior to use this value
79 --> $DIR/ub-ref-ptr.rs:40:1
80 |
81 LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
82 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling reference (address 0x539 is unallocated)
83 |
84 = 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.
85 = note: the raw bytes of the constant (size: 4, align: 4) {
86 39 05 00 00 │ 9...
87 }
88
89 error[E0080]: it is undefined behavior to use this value
90 --> $DIR/ub-ref-ptr.rs:43:1
91 |
92 LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
93 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling box (address 0x539 is unallocated)
94 |
95 = 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.
96 = note: the raw bytes of the constant (size: 4, align: 4) {
97 39 05 00 00 │ 9...
98 }
99
100 error[E0080]: it is undefined behavior to use this value
101 --> $DIR/ub-ref-ptr.rs:46:1
102 |
103 LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init };
104 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized raw pointer
105 |
106 = 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.
107 = note: the raw bytes of the constant (size: 4, align: 4) {
108 __ __ __ __ │ ░░░░
109 }
110
111 error[E0080]: it is undefined behavior to use this value
112 --> $DIR/ub-ref-ptr.rs:49:1
113 |
114 LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
115 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a null function pointer
116 |
117 = 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.
118 = note: the raw bytes of the constant (size: 4, align: 4) {
119 00 00 00 00 │ ....
120 }
121
122 error[E0080]: it is undefined behavior to use this value
123 --> $DIR/ub-ref-ptr.rs:51:1
124 |
125 LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init };
126 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected a proper pointer or integer value
127 |
128 = 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.
129 = note: the raw bytes of the constant (size: 4, align: 4) {
130 __ __ __ __ │ ░░░░
131 }
132
133 error[E0080]: it is undefined behavior to use this value
134 --> $DIR/ub-ref-ptr.rs:53:1
135 |
136 LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
137 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x0000000d, but expected a function pointer
138 |
139 = 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.
140 = note: the raw bytes of the constant (size: 4, align: 4) {
141 0d 00 00 00 │ ....
142 }
143
144 error[E0080]: it is undefined behavior to use this value
145 --> $DIR/ub-ref-ptr.rs:55:1
146 |
147 LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
148 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc43, but expected a function pointer
149 |
150 = 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.
151 = note: the raw bytes of the constant (size: 4, align: 4) {
152 ╾─alloc43─╼ │ ╾──╼
153 }
154
155 error: aborting due to 14 previous errors
156
157 For more information about this error, try `rustc --explain E0080`.