We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d45325c commit 81a556bCopy full SHA for 81a556b
tests/fail/uninit/padding-enum.rs
@@ -17,8 +17,8 @@ fn main() {
17
assert!(matches!(*p.as_ptr(), E::None));
18
19
// Turns out the discriminant is (currently) stored
20
- // in the 2nd pointer, so the first half is padding.
21
- let c = &p as *const _ as *const u8;
+ // in the 1st pointer, so the second half is padding.
+ let c = (&p as *const mem::MaybeUninit<E>).byte_add(mem::size_of::<&'static ()>()) as *const u8;
22
// Read a padding byte.
23
let _val = *c.add(0);
24
//~^ERROR: uninitialized
0 commit comments