3 ms·
With size_t, it would never overflow, even on 32 bits. The input is an array of int, ints are 4 bytes, 32 bit systems can only address 2^32 bytes, so the array
by GuB-42 9y ago
With size_t, it would never overflow, even on 32 bits.
The input is an array of int, ints are 4 bytes, 32 bit systems can only address 2^32 bytes, so the array is no more than 2^30 elements long, so in the worst case, low+high equals 2^31-3, less than even a signed it.
It could overflow if we pass it a char* instead but if you have a >2GB array of sorted single bytes, you probably have a problem somewhere else...