Commit 6be72e6
committed
Use
Casting an arbitrary pointer to `u64` is an undefined behavior.
Not sure if casting of the discriminator value is really necessary, as
it is just a `u8` in this example. But using the same
`*ptr.cast::<uXX>()` pattern in there seems wrong. It is a noop for
`u8`, but if a `u64` is used, it becomes undefined behavior as well.
Also, the `unsafe` usage is somewhat unclear. Dereferencing a pointer
is an unsafe operation, but the first two examples do not have `unsafe`.
Yet in the last example, when a slice is constructed, `unsafe` is
present. I assume that the first two examples are expected to be in an
unsafe context already?read_unaligned when reading u64
1 parent 12601c9 commit 6be72e6
1 file changed
Lines changed: 7 additions & 7 deletions
Lines changed: 7 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
128 | | - | |
129 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
| 148 | + | |
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
157 | | - | |
| 156 | + | |
| 157 | + | |
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
182 | | - | |
| 182 | + | |
0 commit comments