There were two bugs:
1) The overflow detection wasn't working properly due to C++ rules.
The "align up" arithmetic was being performed in 32 bit integers.
2) When we overflow on 32 bit, we are supposed to OOM, not actually
throw an overflow exception.
Fix both issues by simply delegating to the slow path helpers when we have large (65K+ elements) arrays.
With this fix, a small libraries test suite runs to completion on my machine:
There were two bugs: 1) The overflow detection wasn't working properly due to C++ rules. The "align up" arithmetic was being performed in 32 bit integers. 2) When we overflow on 32 bit, we are supposed to OOM, not actually throw an overflow exception.
Fix both issues by simply delegating to the slow path helpers when we have large (65K+ elements) arrays.
With this fix, a small libraries test suite runs to completion on my machine: