|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #36306 crc32() function result differs on 32-bit and 64-bit platforms
Submitted: 2006-02-06 18:34 UTC Modified: 2012-07-26 17:23 UTC
From: anight at eyelinkmedia dot com Assigned: pajoye
Status: Wont fix Package: *General Issues
PHP Version: 4.4.2 OS: independant
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-02-06 18:34 UTC] anight at eyelinkmedia dot com
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":


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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-07 01:27 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.

 [2012-07-26 17:23 UTC]
-Status: Closed +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 [2012-07-26 17:23 UTC]
the fix was actually reverted, see for further details ...
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Thu Nov 26 21:01:33 2015 UTC