rust-lang/rust — pull request #18728 by thestinger (2014-11-07 03:14:12+00:00)
Title: clarify maximum object size semantics in the manual

The compiler currently enforces a `1 << 31` byte address limit to prevent type overflows. Previously, it allowed types to be larger than the available address space. However, this does not prevent offset overflows on 32-bit architectures and is overly conservative on 64-bit. Since pointer differences are inherently signed, the language needs to prevent objects from being larger than the maximum signed `int` value.

For example, slice indexing takes a `uint`, performs and unsigned bounds check and then uses it as a signed integer to perform an offset into the array. This fixes the fixed-size array unsoundness in #18726, and the remaining problem can either be addressed in the memory allocator implementation or the safe APIs making use of it under the hood like `Vec`.