[Webkit-unassigned] [Bug 115047] New: RetainPtr.h should compile with -Wshorten-64-to-32

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Apr 23 10:54:03 PDT 2013


https://bugs.webkit.org/show_bug.cgi?id=115047

           Summary: RetainPtr.h should compile with -Wshorten-64-to-32
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: Unspecified
        OS/Version: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Web Template Framework
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: ddkilzer at webkit.org
                CC: mjs at apple.com, darin at apple.com, benjamin at webkit.org,
                    akling at apple.com
            Blocks: 107093


RetainPtr.h:318:20: error: implicit conversion loses integer precision: 'CFHashCode' (aka 'unsigned long') to 'unsigned int' [-Werror,-Wshorten-64-to-32]
            return CFHash(o.get());
            ~~~~~~ ^~~~~~~~~~~~~~~

CFHash() returns a CFHashCode, which is typedef-ed to 'unsigned long', which is 4 bytes on 32-bit architectures (which matches 'unsigned'), but 8 bytes on 64-bit architectures.

I see two possible fixes here:

1. Use a static_cast<uint32_t>() operator to just take the lower 4 bytes for the hash code.  This is what is implicitly happening now.

2. Use static_cast<uint64_t>() with WTF::intHash() to generate a new 4-byte hash code using the 8-byte CFHashCode.

Thoughts?

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list