Bug 239698 - [WASM] Fix warning: cast from ‘char*’ to ‘JSC::Wasm::Type*’ increases required alignment of target type [-Wcast-align]
Summary: [WASM] Fix warning: cast from ‘char*’ to ‘JSC::Wasm::Type*’ increases require...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebAssembly (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Dmitry
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-04-23 22:14 PDT by Dmitry
Modified: 2022-04-26 19:02 PDT (History)
9 users (show)

See Also:


Attachments
Patch (4.29 KB, patch)
2022-04-23 22:15 PDT, Dmitry
no flags Details | Formatted Diff | Diff
Patch (4.77 KB, patch)
2022-04-25 06:45 PDT, Dmitry
no flags Details | Formatted Diff | Diff
Patch (4.74 KB, patch)
2022-04-25 22:00 PDT, Dmitry
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry 2022-04-23 22:14:17 PDT
[WASM] Fix warning: cast from ‘char*’ to ‘JSC::Wasm::Type*’ increases required alignment of target type [-Wcast-align]
Comment 1 Dmitry 2022-04-23 22:15:56 PDT
Created attachment 458227 [details]
Patch
Comment 2 Yusuke Suzuki 2022-04-24 23:16:46 PDT
Comment on attachment 458227 [details]
Patch

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

Commented.

> Source/JavaScriptCore/wasm/WasmTypeDefinition.h:83
> +    void* const m_payload;

I wonder if we should just change it to `Type*`.

> Source/JavaScriptCore/wasm/WasmTypeDefinition.h:121
> +    void* const m_payload;

How about changing it to `StructField*`?
Comment 3 Dmitry 2022-04-25 06:45:30 PDT
Created attachment 458266 [details]
Patch
Comment 4 Darin Adler 2022-04-25 09:41:17 PDT
Comment on attachment 458266 [details]
Patch

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

> Source/JavaScriptCore/wasm/WasmTypeDefinition.h:132
> +        : m_typeHeader { FunctionSignature { reinterpret_cast<Type*>(payload()), argCount, retCount } }

Casting from void* can and should be done with static_cast instead of reinterpret_cast.

> Source/JavaScriptCore/wasm/WasmTypeDefinition.h:137
> +        : m_typeHeader { StructType { reinterpret_cast<StructField*>(payload()), fieldCount } }

Ditto.

> Source/JavaScriptCore/wasm/WasmTypeDefinition.h:142
> +    void* payload() { return reinterpret_cast<void*>(this + 1); }

This should not need a type cast. TypeDefinition* can be converted to void* without one
Comment 5 Dmitry 2022-04-25 22:00:41 PDT
Created attachment 458328 [details]
Patch
Comment 6 EWS 2022-04-26 19:01:16 PDT
Committed r293492 (250025@main): <https://commits.webkit.org/250025@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 458328 [details].
Comment 7 Radar WebKit Bug Importer 2022-04-26 19:02:15 PDT
<rdar://problem/92372097>