Make the intention of the miri test more clear
This commit is contained in:
parent
c4574cba3b
commit
937b09b389
2 changed files with 5 additions and 4 deletions
|
@ -18,9 +18,10 @@ fn main() {
|
||||||
|
|
||||||
// Turns out the discriminant is (currently) stored
|
// Turns out the discriminant is (currently) stored
|
||||||
// in the 1st pointer, so the second half is padding.
|
// 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;
|
let c = &p as *const _ as *const u8;
|
||||||
|
let padding_offset = mem::size_of::<&'static ()>();
|
||||||
// Read a padding byte.
|
// Read a padding byte.
|
||||||
let _val = *c.add(0);
|
let _val = *c.add(padding_offset);
|
||||||
//~^ERROR: uninitialized
|
//~^ERROR: uninitialized
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
|
||||||
--> tests/fail/uninit/padding-enum.rs:LL:CC
|
--> tests/fail/uninit/padding-enum.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let _val = *c.add(0);
|
LL | let _val = *c.add(padding_offset);
|
||||||
| ^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
|
| ^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
|
||||||
|
|
|
|
||||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
||||||
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue