Skip to content
Discussion options

You must be logged in to vote

This is just to help avoid issues with integer overflow, as per:

inline SIZE_T MaxArrayLength()
{
// Impose limits on maximum array length to prevent corner case integer overflow bugs
// Keep in sync with Array.MaxLength in BCL.
return 0X7FFFFFC7;
}

There is various logic that needs to do offset and other calculations using the number of elements and a slightly smaller limit helps avoid potential issues, making typical code more robust without being limiting.

Notably, allocating such large arrays, regardless of what the actual runtime limit is, has other fundamental problems and is …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@colejohnson66
Comment options

@tannergooding
Comment options

Answer selected by semihartan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants