[Webkit-unassigned] [Bug 227170] Prevent sign-extended casts for 32 bits arch

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Jun 21 08:44:49 PDT 2021


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

--- Comment #7 from Mikhail R. Gadelha <mikhail at igalia.com> ---
Comment on attachment 431781
  --> https://bugs.webkit.org/attachment.cgi?id=431781
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=431781&action=review

>>> Source/WTF/wtf/LoggerHelper.h:79
>>> +        return reinterpret_cast<const void*>((reinterpret_cast<uintptr_t>(parentIdentifier) & parentMask) | (childIdentifier & maskLowerWord));
>> 
>> Ditto.
> 
> Is this correct? We are using `static constexpr uint64_t`

The compiler will introduce an implicit cast from uintptr_t to uint64_t in 32 bits mode... Here's the clang ast dump (I actually just copied the function to a separate file but it should generate the same code during compilation):

      | `-BinaryOperator 0x5655a48 <col:47, col:91> 'unsigned long long' '&'
HERE->|   |-ImplicitCastExpr 0x5655a30 <col:47, col:87> 'unsigned long long' <IntegralCast>
      |   | `-CallExpr 0x5655998 <col:47, col:87> 'unsigned int':'unsigned int'
      |   |   |-ImplicitCastExpr 0x5655980 <col:47, col:69> 'unsigned int (*)(const void *)' <FunctionToPointerDecay>
      |   |   | `-DeclRefExpr 0x56558b8 <col:47, col:69> 'unsigned int (const void *)' lvalue Function 0x56557a0 'bitwise_cast' 'unsigned int (const void *)' (FunctionTemplate 0x5653770 'bitwise_cast')
      |   |   `-ImplicitCastExpr 0x56559c0 <col:71> 'const void *' <LValueToRValue>
      |   |     `-DeclRefExpr 0x56554e0 <col:71> 'const void *' lvalue ParmVar 0x5654f98 'parentIdentifier' 'const void *'
      |   `-ImplicitCastExpr 0x5655a18 <col:91> 'uint64_t':'unsigned long long' <LValueToRValue>
      |     `-DeclRefExpr 0x56559f8 <col:91> 'const uint64_t':'const unsigned long long' lvalue Var 0x5655218 'parentMask' 'const uint64_t':'const unsigned long long' non_odr_use_constant

No implicit cast is added in 64 bits mode.

-- 
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/20210621/dd571b2b/attachment.htm>


More information about the webkit-unassigned mailing list