php.net |  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
Votes:3
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: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: fwmatt at dsl dot pipex dot com
New email:
PHP Version: OS:

 

 [2006-09-10 15:55 UTC] fwmatt at dsl dot pipex dot com
Description:
------------
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:
----------------
Array
(
    [1] => -30000
)

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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-10 16:03 UTC] tony2001@php.net
http://php.net/pack:

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] iliaa@php.net
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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 00:01:27 2024 UTC