|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38770 pack/unpack is broken on 64bit
Submitted: 2006-09-10 15:55 UTC Modified: 2007-09-03 08:13 UTC
Avg. Score:4.0 ± 0.8
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: fwmatt at dsl dot pipex dot com Assigned:
Status: Closed Package: Strings related
PHP Version: 5.1.6 OS: Linux x86_64
Private report: No CVE-ID:
 [2006-09-10 15:55 UTC] fwmatt at dsl dot pipex dot com
On my 32bit x86 system the attached code produces the expected results, however on my x86 64bit system it produces the (actual) attached.

Reproduce code:
print_r( unpack( "N", pack( 'N', -30000 ) ));

Expected result:
    [1] => -30000

Actual result:
    [1] => 4294937296


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-10 16:03 UTC]

N - unsigned long (always 32 bit, big endian byte order)
 [2006-09-10 16:31 UTC] fwmatt at dsl dot pipex dot com
Sorry for re-opening this but;

Why should the same code produce different output on a 64bit machine than it does on a 32bit machine ? 

If 4294937296 is the expect result then it is broken on 32bit machines where it returns -30000.
 [2006-11-19 18:21 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Sat Nov 28 05:01:34 2015 UTC