1
1
error[E0080]: it is undefined behavior to use this value
2
- --> $DIR/ub-ref-ptr.rs:16 :1
2
+ --> $DIR/ub-ref-ptr.rs:15 :1
3
3
|
4
4
LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
5
5
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
@@ -10,7 +10,7 @@ LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
10
10
}
11
11
12
12
error[E0080]: it is undefined behavior to use this value
13
- --> $DIR/ub-ref-ptr.rs:20 :1
13
+ --> $DIR/ub-ref-ptr.rs:19 :1
14
14
|
15
15
LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
16
16
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1)
@@ -21,7 +21,7 @@ LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
21
21
}
22
22
23
23
error[E0080]: it is undefined behavior to use this value
24
- --> $DIR/ub-ref-ptr.rs:24 :1
24
+ --> $DIR/ub-ref-ptr.rs:23 :1
25
25
|
26
26
LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
27
27
| ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference
@@ -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:27 :1
35
+ --> $DIR/ub-ref-ptr.rs:26 :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:34 :1
46
+ --> $DIR/ub-ref-ptr.rs:33 :1
47
47
|
48
48
LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
49
49
| ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
@@ -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:37 :39
55
+ --> $DIR/ub-ref-ptr.rs:36 :39
56
56
|
57
57
LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
58
58
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
@@ -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 used
64
- --> $DIR/ub-ref-ptr.rs:37 :38
64
+ --> $DIR/ub-ref-ptr.rs:36 :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:40 :86
70
+ --> $DIR/ub-ref-ptr.rs:39 :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 raw bytes
@@ -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 used
79
- --> $DIR/ub-ref-ptr.rs:40 :85
79
+ --> $DIR/ub-ref-ptr.rs:39 :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:43 :1
85
+ --> $DIR/ub-ref-ptr.rs:42 :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:46 :1
96
+ --> $DIR/ub-ref-ptr.rs:45 :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:49 :41
107
+ --> $DIR/ub-ref-ptr.rs:48 :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:53 :1
113
+ --> $DIR/ub-ref-ptr.rs:52 :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:55 :38
124
+ --> $DIR/ub-ref-ptr.rs:54 :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:58 :1
130
+ --> $DIR/ub-ref-ptr.rs:57 :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:60 :1
141
+ --> $DIR/ub-ref-ptr.rs:59 :1
142
142
|
143
143
LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
144
144
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered alloc41, but expected a function pointer
@@ -158,7 +158,7 @@ note: inside `std::ptr::read::<u32>`
158
158
note: inside `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:67 :5
161
+ --> $DIR/ub-ref-ptr.rs:66 :5
162
162
|
163
163
LL | ptr.read();
164
164
| ^^^^^^^^^^
0 commit comments