Closed
Description
Type size calculations inside the compiler can overflow, resulting in memory unsafety. Types without a valid mem::size_of
should be forbidden to prevent unsoundness. Types that are valid today would become invalid and this would interfere with an attempt to support integer type parameters. I think it's a serious backwards compatibility issue since the interaction with generics is very bad.
std::mem::size_of::<[[u8, ..!0u], ..!0u]>()
returns 1, since !0u * !0u
wraps to 1
. The same thing can be done with other aggregate types like structs / tuples and an overflow could also occur from the tag added in an enum
.