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
use std::mem;#[repr(packed(2),C)]structSlice([u32]);structPackedSized{f:u8,d:[u32;4],}structPackedUnsized{f:u8,d:Slice,}implPackedSized{fnunsize(&self) -> &PackedUnsized{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);}}
original:
use std::mem;#[repr(packed(2),C)]structSlice([u32]);#[repr(packed(2),C)]structPackedSized{f:u8,d:[u32;4],}#[repr(packed(2),C)]structPackedUnsized{f:u8,d:Slice,}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);}}
auto-reduced (treereduce-rust):
original:
Version information
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcodegen-backend=cranelift
Program output
The text was updated successfully, but these errors were encountered: