Why does Rust throw an error for a `[u8; isize::MAX as usize / 4 + 1]`, even though the theoretical allocation limit is `isize::MAX`?
03:56 25 Jun 2026

Here is a reproducible example:

fn main() {
    let _: [u8; isize::MAX as usize / 4];
    let _: [u8; isize::MAX as usize / 4 + 1];

    let _a: [u8; isize::MAX as usize / 4];
    let _b: [u8; isize::MAX as usize / 4 + 1];
}

It fails with the following error:

error: values of the type `[u8; 2305843009213693952]` are too big for the target architecture
 --> src/main.rs:6:9
  |
6 |     let _b: [u8; isize::MAX as usize / 4 + 1];
  |         ^^

error: could not compile `lab` (bin "lab") due to 1 previous error

This makes me wonder:

  • What exactly causes this error?
  • Is this behavior documented?
  • Why is line 3 accepted?
rust