You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This assertion passes with rustc but not with Miri:
use std::mem;#[repr(packed,C)]structPackedSized{f:u8,d:[u32;4],}#[repr(packed,C)]structPackedUnsized{f:u8,d:[u32],}implPackedSized{fnunsize(&self) -> &PackedUnsized{// We can't unsize via a generic type since then we get the error// that packed structs with unsized tail don't work if the tail// might need dropping.let len = 4usize;unsafe{ mem::transmute((self, len))}}}fnmain(){unsafe{let p = PackedSized{f:0,d:[1,2,3,4]};let p = p.unsize()as*constPackedUnsized;let d = std::ptr::addr_of!((*p).d);assert_eq!(d.cast::<u32>().read_unaligned(), 1);}}
The text was updated successfully, but these errors were encountered:
Rollup merge of rust-lang#118540 - RalfJung:unsized-packed-offset, r=TaKO8Ki
codegen, miri: fix computing the offset of an unsized field in a packed struct
`#[repr(packed)]` strikes again.
Fixesrust-lang#118537Fixesrust-lang/miri#3200
`@bjorn3` I assume cranelift needs the same fix.
codegen, miri: fix computing the offset of an unsized field in a packed struct
`#[repr(packed)]` strikes again.
Fixesrust-lang/rust#118537Fixes#3200
`@bjorn3` I assume cranelift needs the same fix.
This assertion passes with rustc but not with Miri:
The text was updated successfully, but these errors were encountered: