@@ -32,7 +32,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
32
32
}
33
33
34
34
error[E0080]: it is undefined behavior to use this value
35
- --> $DIR/ub-ref-ptr.rs:26 :1
35
+ --> $DIR/ub-ref-ptr.rs:27 :1
36
36
|
37
37
LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
38
38
| ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box
@@ -43,7 +43,7 @@ LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
43
43
}
44
44
45
45
error[E0080]: evaluation of constant value failed
46
- --> $DIR/ub-ref-ptr.rs:33 :1
46
+ --> $DIR/ub-ref-ptr.rs:35 :1
47
47
|
48
48
LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
49
49
| ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@@ -52,7 +52,7 @@ LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
52
52
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
53
53
54
54
error[E0080]: evaluation of constant value failed
55
- --> $DIR/ub-ref-ptr.rs:36 :39
55
+ --> $DIR/ub-ref-ptr.rs:38 :39
56
56
|
57
57
LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
58
58
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@@ -61,13 +61,13 @@ LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
61
61
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
62
62
63
63
note: erroneous constant encountered
64
- --> $DIR/ub-ref-ptr.rs:36 :38
64
+ --> $DIR/ub-ref-ptr.rs:38 :38
65
65
|
66
66
LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
67
67
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
68
68
69
69
error[E0080]: evaluation of constant value failed
70
- --> $DIR/ub-ref-ptr.rs:39 :86
70
+ --> $DIR/ub-ref-ptr.rs:41 :86
71
71
|
72
72
LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
73
73
| ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@@ -76,13 +76,13 @@ LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[us
76
76
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
77
77
78
78
note: erroneous constant encountered
79
- --> $DIR/ub-ref-ptr.rs:39 :85
79
+ --> $DIR/ub-ref-ptr.rs:41 :85
80
80
|
81
81
LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
82
82
| ^^^^^^^^^^^^^^^^^^^^^
83
83
84
84
error[E0080]: it is undefined behavior to use this value
85
- --> $DIR/ub-ref-ptr.rs:42 :1
85
+ --> $DIR/ub-ref-ptr.rs:44 :1
86
86
|
87
87
LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
88
88
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance)
@@ -93,7 +93,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
93
93
}
94
94
95
95
error[E0080]: it is undefined behavior to use this value
96
- --> $DIR/ub-ref-ptr.rs:45 :1
96
+ --> $DIR/ub-ref-ptr.rs:48 :1
97
97
|
98
98
LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
99
99
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance)
@@ -104,13 +104,13 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
104
104
}
105
105
106
106
error[E0080]: evaluation of constant value failed
107
- --> $DIR/ub-ref-ptr.rs:48 :41
107
+ --> $DIR/ub-ref-ptr.rs:52 :41
108
108
|
109
109
LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init };
110
110
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
111
111
112
112
error[E0080]: it is undefined behavior to use this value
113
- --> $DIR/ub-ref-ptr.rs:52 :1
113
+ --> $DIR/ub-ref-ptr.rs:56 :1
114
114
|
115
115
LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
116
116
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer
@@ -121,13 +121,13 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
121
121
}
122
122
123
123
error[E0080]: evaluation of constant value failed
124
- --> $DIR/ub-ref-ptr.rs:54 :38
124
+ --> $DIR/ub-ref-ptr.rs:59 :38
125
125
|
126
126
LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init };
127
127
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
128
128
129
129
error[E0080]: it is undefined behavior to use this value
130
- --> $DIR/ub-ref-ptr.rs:57 :1
130
+ --> $DIR/ub-ref-ptr.rs:62 :1
131
131
|
132
132
LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
133
133
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer
@@ -138,7 +138,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
138
138
}
139
139
140
140
error[E0080]: it is undefined behavior to use this value
141
- --> $DIR/ub-ref-ptr.rs:59 :1
141
+ --> $DIR/ub-ref-ptr.rs:65 :1
142
142
|
143
143
LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
144
144
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC2<imm>, but expected a function pointer
@@ -158,13 +158,13 @@ note: inside `std::ptr::read::<u32>`
158
158
note: inside `std::ptr::const_ptr::<impl *const u32>::read`
159
159
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
160
160
note: inside `UNALIGNED_READ`
161
- --> $DIR/ub-ref-ptr.rs:66 :5
161
+ --> $DIR/ub-ref-ptr.rs:73 :5
162
162
|
163
163
LL | ptr.read();
164
164
| ^^^^^^^^^^
165
165
166
166
error[E0080]: it is undefined behavior to use this value
167
- --> $DIR/ub-ref-ptr.rs:69 :1
167
+ --> $DIR/ub-ref-ptr.rs:76 :1
168
168
|
169
169
LL | const POINTS_TO_FUNCTION: &() = unsafe {
170
170
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a function
@@ -175,7 +175,7 @@ LL | const POINTS_TO_FUNCTION: &() = unsafe {
175
175
}
176
176
177
177
error[E0080]: it is undefined behavior to use this value
178
- --> $DIR/ub-ref-ptr.rs:74 :1
178
+ --> $DIR/ub-ref-ptr.rs:81 :1
179
179
|
180
180
LL | const POINTS_TO_VTABLE: (&(), &()) = unsafe {
181
181
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .1: encountered a reference pointing to a vtable
0 commit comments