Edit report at http://bugs.php.net/bug.php?id=51430&edit=1

 ID:               51430
 Updated by:       tony2...@php.net
 Reported by:      will at flourishlib dot com
 Summary:          Numeric string array key is being implicitly cast to
                   32bit int and overflowing
-Status:           Open
+Status:           Bogus
 Type:             Bug
 Package:          Scripting Engine problem
 Operating System: Fedora 12
 PHP Version:      5.3.2

 New Comment:

Not reproducible with 5.3.2, 5.3.3-dev and trunk on 64bit Linux.


Previous Comments:
------------------------------------------------------------------------
[2010-03-29 20:18:41] will at flourishlib dot com

Description:
------------
When trying to use a string array key that contains a number outside of
the 32bit integer range, the key is being cast to an integer implicitly
by PHP and is overflowing the 32bit integer limits.



This incorrect casting is present in both 5.3.1 and 5.3.2 (probably
5.3.0), however 5.1.6 through 5.2.13 do not perform this implicit
casting. The manual indicates that an integer-like key will be cast to
an integer, however that should not be the case when the integer will
not losslessly cast, since that can cause keys to be overwritten.

Test script:
---------------
print_r(array("-2147483649" => TRUE, "-2147483648" => FALSE));

print_r(array("-2147483649" => 1, "-2147483648" => 2, "2147483647" => 3,
"2147483648" => 4));

Expected result:
----------------
Array

(

    [-2147483649] => 1

    [-2147483648] =>

)

Array

(

    [-2147483649] => 1

    [-2147483648] => 2

    [2147483647] => 3

    [2147483648] => 4

)

Actual result:
--------------
Array

(

    [2147483647] => 1

    [-2147483648] =>

)

Array

(

    [2147483647] => 3

    [-2147483648] => 4

)




------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=51430&edit=1

Reply via email to