php.net |  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 (profile)
Status: Wont fix Package: *General Issues
PHP Version: 4.4.2 OS: independant
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: anight at eyelinkmedia dot com
New email:
PHP Version: OS:

 

 [2006-02-06 18:34 UTC] 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


Patches

Pull Requests

History

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


 [2012-07-26 17:23 UTC] hholzgra@php.net
-Status: Closed +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 [2012-07-26 17:23 UTC] hholzgra@php.net
the fix was actually reverted, see http://php.net/crc32 for further details ...
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Feb 01 02:01:30 2025 UTC