From: Operating system: Fedora 12 PHP version: 5.3.2 Package: Scripting Engine problem Bug Type: Bug Bug description:Numeric string array key is being implicitly cast to 32bit int and overflowing
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 bug report at http://bugs.php.net/bug.php?id=51430&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51430&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51430&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51430&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=51430&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51430&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=51430&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=51430&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=51430&r=needscript Try newer version: http://bugs.php.net/fix.php?id=51430&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=51430&r=support Expected behavior: http://bugs.php.net/fix.php?id=51430&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=51430&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=51430&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=51430&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51430&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=51430&r=dst IIS Stability: http://bugs.php.net/fix.php?id=51430&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=51430&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=51430&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=51430&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=51430&r=mysqlcfg