ID:               40543
 Comment by:       petr dot stastny at centrum dot cz
 Reported By:      dedmajor at gmail dot com
 Status:           Open
 Bug Type:         Strings related
 Operating System: linux x86_64
 PHP Version:      5.2.1
 New Comment:

Sorry, it is converted to SIGNED int


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

[2007-04-22 18:43:53] petr dot stastny at centrum dot cz

The problem is that first 32 bits are set to 1 (not 0) in the output of
unpack() function, thus it is interpreted as very large number and then
converted to unsigned int for PHP representation.

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

[2007-04-12 20:11:55] [EMAIL PROTECTED]

This isn't bogus, this is a real bug that causes pain.
N is there for people writing code that talks to network services that
need to convert numbers from network byte order to the native format.

Also note that we get a bonus crash bug on 64-bit platforms too:

$fail = '\x00\x00\x00\x8c';
$result = unpack('Nsize', $fail);
$size = $result['size'] & 0xffffffff;  // BANG!

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

[2007-02-24 15:12:29] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You should be using either L or V, not N.

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

[2007-02-19 13:34:38] dedmajor at gmail dot com

Description:
------------
#38770 not fixed(?) in 5.2.1-dev

on x86_64 AMD Opteron(tm) Processor 265 unpack don't work, on i686
Intel(R) Celeron(R) CPU 2.50GHz works fine for example.

Reproduce code:
---------------
php -r 'print_r(unpack("N", pack("N", 41445)));

Expected result:
----------------
Array
(
    [1] => 41445
)


Actual result:
--------------
Array
(
    [1] => -2147442203
)


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


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

Reply via email to