#36306 [NEW]: crc32() function result differs on 32-bit and 64-bit platforms
| From: | anight at eyelinkmedia dot com | Date: | Mon, 06 Feb 2006 17:34:30 +0000 |
| Subject: | #36306 [NEW]: crc32() function result differs on 32-bit and 64-bit platforms | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-92988@lists.php.net to get a copy of this message | ||
From: anight at eyelinkmedia dot com
Operating system: independant
PHP version: 4.4.2
PHP Bug Type: Feature/Change Request
Bug description: crc32() function result differs on 32-bit and 64-bit platforms
Description:
------------
I noticed that crc32() function result is represented differently on
32-bit and 64-bit platforms. The problem is whithin crc32.c file,
unsigned int crc = ~0;
After actual crc32 calculations result is inverted and then casted to
"long":
RETVAL_LONG(~crc);
Proposed patch:
RETVAL_LONG(~ (long) crc);
I tested it successfully on 64-bit linux and macosx, it works well.
Reproduce code:
---------------
<? echo crc32("platform independant") . "\n"; ?>
Expected result:
----------------
I expect to see value -858128794 both on 32-bit and 64-bit platform.
Actual result:
--------------
On 64-bit platform i see 3436838502
On 32-bit -858128794
--
Edit bug report at http://bugs.php.net/?id=36306&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36306&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36306&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36306&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=36306&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=36306&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=36306&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=36306&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=36306&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=36306&r=support
Expected behavior: http://bugs.php.net/fix.php?id=36306&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=36306&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=36306&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=36306&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36306&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=36306&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=36306&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=36306&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=36306&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=36306&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=36306&r=mysqlcfg