Bug 233720

Summary: Add static_assert the value we use to initialize a StructureID buffer should be 0.
Product: WebKit Reporter: Keith Miller <keith_miller>
Component: New BugsAssignee: Keith Miller <keith_miller>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, mark.lam, mcatanzaro, msaboff, saam, tzagallo, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=233379
Attachments:
Description Flags
Patch
none
Patch for landing none

Description Keith Miller 2021-12-01 13:23:23 PST
Fix GCC warning about memcpy into a StructureID* buffer
Comment 1 Keith Miller 2021-12-01 13:24:00 PST
Created attachment 445606 [details]
Patch
Comment 2 Yusuke Suzuki 2021-12-01 13:26:16 PST
Comment on attachment 445606 [details]
Patch

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

> Source/JavaScriptCore/runtime/StructureChain.cpp:52
> +    static_assert(!StructureID().bits(), "Make sure the value we're going to memcpy below matches the default StructureID");

This part looks good.

> Source/JavaScriptCore/runtime/StructureID.h:55
> +    constexpr uint32_t bits() const { return m_bits; }

Nice.
Comment 3 Keith Miller 2021-12-01 13:32:47 PST
Created attachment 445607 [details]
Patch for landing
Comment 4 Michael Catanzaro 2021-12-01 13:45:21 PST
Comment on attachment 445607 [details]
Patch for landing

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

> Source/JavaScriptCore/runtime/StructureChain.cpp:53
>      memset(vector, 0, bytes);

I'm skeptical that would be enough to suppress this warning. We'll probably need to do:

memset(static_cast<void*>(vector), 0, bytes);

If your patch alone isn't enough, I'll just commit this as a follow-up.
Comment 5 Keith Miller 2021-12-01 13:46:17 PST
(In reply to Michael Catanzaro from comment #4)
> Comment on attachment 445607 [details]
> Patch for landing
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=445607&action=review
> 
> > Source/JavaScriptCore/runtime/StructureChain.cpp:53
> >      memset(vector, 0, bytes);
> 
> I'm skeptical that would be enough to suppress this warning. We'll probably
> need to do:
> 
> memset(static_cast<void*>(vector), 0, bytes);
> 
> If your patch alone isn't enough, I'll just commit this as a follow-up.

Oh, this is just the static_assert now since Yusuke already landed a cast change.
Comment 6 Michael Catanzaro 2021-12-01 13:47:12 PST
Ack, see: bug #233379 for the warning fix.
Comment 7 EWS 2021-12-01 14:24:50 PST
Committed r286387 (244744@main): <https://commits.webkit.org/244744@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 445607 [details].
Comment 8 Radar WebKit Bug Importer 2021-12-01 14:25:24 PST
<rdar://problem/85939821>