Hello everyone!

I was working on following request https://bugs.php.net/bug.php?id=75053 
<https://bugs.php.net/bug.php?id=75053> which resulted in following pull 
request https://github.com/php/php-src/pull/2676 

The problem here is following: when we’re using large numbers as array index 
when adding new elements it could overwrite already existing value.
Assume we have 2 indexes 5076964154930102272 and 999999999999999999999999999999 
with different value set for them.

Because 999999999999999999999999999999 is larger than maximum long int number 
for 64-bit systems, it will be converted to double. (corresponding code here 
But when double value is used as array indexes, it is converted to long 
integer. (f.e., code is here 
At this case it causes overflow and we’ve got index equal to 
5076964154930102272 and as a result - we’re overwriting previously set value.

My suggestion is following:
1) when double key is less than maximum possible long integer - convert it to 
2) if it’s larger - convert it to string.

That’s what implemented in proposed PR.

Another possible option is just to throw warning in this case (proposed by 
Nikita Popov)

I would happy to hear any feedback and suggestions about this solution.

Reply via email to