On Sat, May 17, 2014 at 9:01 PM, Nikita Nefedov <inefedor@gmail.com> wrote:
Hey,
First thank you for arranging all this points.
I just wanted to ask: could we also make nNextFreeElement be unsigned? Because with your proposal it >>would be possible to overflow it with the code like this: $array[pow(2, 32) + 1] = 123; (if I understand >>it correctly)
And besides that we can't have negative keys anyway.
PHP arrays store integral keys larger than PHP_INT_MAX as a string rather than an integer. Auto->incrementing does not work past that point. If you write something like this...
$array[PHP_INT_MAX] = 42;
$array[] = 43;
...you'll receive an error (this is intentional). You get that error because the code explicitly makes >sure that nNextFreeElement can never overflow. (Here is an example of such an overflow check:
http://>lxr.php.net/xref/PHP_TRUNK/Zend/zend_hash.c#435).
Nikita
Ah well, my fault didn't see it :)