Skip to content

Commit

Permalink
Don't rely on unspecified struct layouts in miri test
Browse files Browse the repository at this point in the history
With additional range metadata the lengh of a wide ref can become the niche
and therefore the pointer will be the padding instead.
  • Loading branch information
the8472 committed Oct 10, 2024
1 parent 78ab350 commit 6671c90
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/tools/miri/tests/fail/uninit/padding-wide-ptr.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
use std::mem;

// If this is `None`, the metadata becomes padding.
type T = Option<&'static str>;
#[repr(C)]
struct RefAndLen {
ptr: &'static u8,
len: usize,
}

// If this is `None`, the len becomes padding.
type T = Option<RefAndLen>;

fn main() {
unsafe {
Expand Down

0 comments on commit 6671c90

Please sign in to comment.