ID:               46701
 User updated by:  testuzer at hotmail dot com
-Summary:          Creating associative array with long values in the key
                   fails under linux
 Reported By:      testuzer at hotmail dot com
 Status:           Verified
 Bug Type:         Arrays related
-Operating System: Linux - ubuntu
+Operating System: Linux 32bit - ubuntu
 PHP Version:      5CVS, 6CVS (2008-11-28)
 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------

[2008-11-29 06:18:33] testuzer at hotmail dot com

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
)

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

[2008-11-28 20:10:29] [EMAIL PROTECTED]

Is this really only happening with array indexes...? Either way, the
bug title isn't accurate.

If it's only with array indexes, it shouldn't be hexadecimal-related,
but would be coming from the simple (long) cast of any double value
(from "long values in the key") in zend_hash_*, resulting in "undefined
behavior."

But, are those values even correct before the array part gets
processed? e.g. does var_dump(0xcc5c4600) give 3428599296? If not, then
it's obviously not array-specific. :-) Hmm, I was just going to say, see
Bug #45068 for the possible cause (and
http://news.php.net/php.internals/40199), but I just noticed that you
marked that Bogus Jani? Cross-compiling isn't supported? Well, I guess
you're not doing that then when reproducing this... How about you, bug
reporter?

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

[2008-11-28 12:37:40] [EMAIL PROTECTED]

Same result with 32bit linux, this is with 64bit:

# php t.php

Array
(
    [3428599296] => 1
    [3459455488] => 1
    [3459616768] => 1
)


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

[2008-11-27 21:04:17] 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
)



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


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

Reply via email to