In order to better detect code that rely on unspecified behavior related to memory layout, it could be useful to have a -Zrandomize-layout flag that add some padding bytes at the start of all #[repr(rust)] structs and unions. It should also add different amounts of padding to different fields.
This should help detecting invalid transmutes, or invalid unions.
Zulip thread: https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Transmute.20safety.20question
In order to better detect code that rely on unspecified behavior related to memory layout, it could be useful to have a
-Zrandomize-layoutflag that add some padding bytes at the start of all#[repr(rust)]structs and unions. It should also add different amounts of padding to different fields.This should help detecting invalid transmutes, or invalid unions.
Zulip thread: https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Transmute.20safety.20question