#36306 [Opn->Csd]: crc32() function result differs on 32-bit and 64-bit platforms
| From: | pajoye@php.net | Date: | Tue, 07 Feb 2006 00:27:10 +0000 |
| Subject: | #36306 [Opn->Csd]: crc32() function result differs on 32-bit and 64-bit platforms | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-92992@lists.php.net to get a copy of this message | ||
ID: 36306
Updated by: pajoye@php.net
Reported By: anight at eyelinkmedia dot com
-Status: Open
+Status: Closed
Bug Type: Feature/Change Request
Operating System: independant
PHP Version: 4.4.2
-Assigned To:
+Assigned To: pajoye
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2006-02-06 18:34:27] anight at eyelinkmedia dot com
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 this bug report at http://bugs.php.net/?id=36306&edit=1