[Webkit-unassigned] [Bug 217805] Open source clang warning: bitwise operation between different enumeration types [-Wenum-enum-conversion]

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Oct 15 20:37:51 PDT 2020


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

--- Comment #1 from David Kilzer (:ddkilzer) <ddkilzer at webkit.org> ---
Interestingly, this constructor doesn't generate a warning, maybe because `s_hashFlag8BitBuffer` lets the compiler implicitly convert the enums to unsigned values:

inline StringImpl::StringImpl(unsigned length, Force8Bit)
    : StringImplShape(s_refCountIncrement, length, tailPointer<LChar>(), s_hashFlag8BitBuffer | StringNormal | BufferInternal)

So instead of applying static_cast<unsigned>() for these cases, we might be able to start with an unsigned value of zero as the initial bitwise value, and let the enum values be converted implicitly:

-     : StringImplShape(s_refCountIncrement, length, tailPointer<UChar>(), StringNormal | BufferInternal)
+     : StringImplShape(s_refCountIncrement, length, tailPointer<UChar>(), 0U | StringNormal | BufferInternal)

It's a bit mysterious why the "0U | " is there later, though.  Maybe we can create a constexpr value like this:

        static constexpr const unsigned s_hashZeroBaseValue = 0;

And then do this:

+     : StringImplShape(s_refCountIncrement, length, tailPointer<UChar>(), s_hashZeroBaseValue | StringNormal | BufferInternal)

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20201016/bb862794/attachment-0001.htm>


More information about the webkit-unassigned mailing list