Bug #72315 [NEW]: Unpack 'J' & 'P' doesn't produce expected results

From: Date: Thu, 02 Jun 2016 10:56:51 +0000
Subject: Bug #72315 [NEW]: Unpack 'J' & 'P' doesn't produce expected results
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201401@lists.php.net to get a copy of this message
From: ads at tristanleboss dot net Operating system: Windows 7 x64 PHP version: 7.0.7 Package: *Mail Related Bug Type: Bug Bug description:Unpack 'J' & 'P' doesn't produce expected results Description: ------------ Hello, While doing some tests, I discovered the 'P' format (unsigned long long (always 64 bit, little endian byte order)) and the 'J' format (unsigned long long (always 64 bit, big endian byte order)) are not giving the expected results on my Windows 7 x64 test machine with PHP 7.0.7RC1. Indeed, they don't account for the "unsigned" nature and output the signed version. Indeed: unpack('P', "\xC0\x00\xF8\x90\x32\x04\x00\x90") will output "-8070445917020880704". The expected result is "13835331353480265872". unpack('J', "\xC0\x00\xF8\x90\x32\x04\x00\x90") will output "-4611412720229285744". The expected result is "10376298156688670912". No error/warning message will be displayed. Test script: --------------- <?php var_dump( unpack('P', "\xC0\x00\xF8\x90\x32\x04\x00\x90") ); var_dump( unpack('J', "\xC0\x00\xF8\x90\x32\x04\x00\x90") ); Expected result: ---------------- array(1) { [1]=> int(13835331353480265872) } array(1) { [1]=> int(10376298156688670912) } Actual result: -------------- array(1) { [1]=> int(-8070445917020880704) } array(1) { [1]=> int(-4611412720229285744) } -- Edit bug report at https://bugs.php.net/bug.php?id=72315&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72315&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72315&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72315&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=72315&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=72315&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=72315&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=72315&r=needscript Try newer version: https://bugs.php.net/fix.php?id=72315&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=72315&r=support Expected behavior: https://bugs.php.net/fix.php?id=72315&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=72315&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=72315&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=72315&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72315&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=72315&r=dst IIS Stability: https://bugs.php.net/fix.php?id=72315&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=72315&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=72315&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=72315&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=72315&r=mysqlcfg

« previous php.bugs (#201401) next »