|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-11-27 21:04 UTC] testuzer at hotmail dot com
Description:
------------
Creating associative array with long values in the key fails under linux builds but work under windows.
Reproduce code:
---------------
$test_array = array(
0xcc5c4600 => 1,
0xce331a00 => 1,
0xce359000 => 1,
);
print_r( $test_array );
Expected result:
----------------
Array
(
[-866368000] => 1
[-835511808] => 1
[-835350528] => 1
)
Actual result:
--------------
Array
(
[-2147483648] => 1
)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 11:00:01 2025 UTC |
Same result with 32bit linux, this is with 64bit: # php t.php Array ( [3428599296] => 1 [3459455488] => 1 [3459616768] => 1 )Here is a simple test: Reproduce code: --------------- echo 0xcc5c4600; var_dump( 0xcc5c4600 ); print_r( 0xcc5c4600 ); For both Windows and Linux - ubuntu the result is the same. Actual result Windows 32bit: -------------- 3428599296 float(3428599296) 3428599296 Actual result Linux 32bit: -------------- 3428599296 float 3428599296 3428599296 So it is not a hex to long conversion problem. Running the same array test using decimals and same values. Reproduce code: --------------- $test_array = array( 3428599296 => 1, 3459455488 => 1, 3459616768 => 1 ); print_r( $test_array ); Actual result Windows 32bit: -------------- Array ( [-866368000] => 1 [-835511808] => 1 [-835350528] => 1 ) Actual result Linux 32bit: -------------- Array ( [-2147483648] => 1 )Can also confirm Linux -ubuntu 64bit works. Actual result Linux 64bit (php 5.2.4): -------------- Array ( [3428599296] => 1 [3459455488] => 1 [3459616768] => 1 ) Obviously the 32bit os treats it as a signed 32bit value and a 64bit os as a 64bit value..... so you get a positive value. The array key handling is _only_ broken on linux 32bit.OS: Debian Linux 2.6.18-6-686 (32bit) PHP: 5.2.0-8+etch13 Result: Array ( [-2147483648] => 1 )Array ( [-2147483648] => 1 ) Reproduced here.The test fails for me: [jani@localhost tests]$ cat bug46701.diff 001+ array(1) { 002+ [-2147483648]=> 003+ int(3) 004+ } 005+ int(3) 006+ array(1) { 007+ [-2147483648]=> 001- array(3) { 002- [-866368000]=> 003- int(1) 004- [-835511808]=> 005- int(2) 006- [-835350528]=> 009- int(2) 010- array(1) { 011- [-835350528]=> 012- int(3) 013- }