Bug 196343 - Opcode.h(159,27): warning: adding 'unsigned int' to a string does not append to the string [-Wstring-plus-int]
Summary: Opcode.h(159,27): warning: adding 'unsigned int' to a string does not append ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Fujii Hironori
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-03-28 02:13 PDT by Fujii Hironori
Modified: 2019-03-28 18:30 PDT (History)
6 users (show)

See Also:


Attachments
Patch (2.75 KB, patch)
2019-03-28 02:38 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (2.81 KB, patch)
2019-03-28 02:53 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (3.64 KB, patch)
2019-03-28 03:19 PDT, Fujii Hironori
saam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fujii Hironori 2019-03-28 02:13:02 PDT
Clang 8.0.0 reports the following compilation warning.

> [1229/6361] Building CXX object Source\JavaScriptCore\CMakeFiles\LLIntOffsetsExtractor.dir\llint\LLIntOffsetsExtractor.cpp.obj
> In file included from ..\..\Source\JavaScriptCore\llint\LLIntOffsetsExtractor.cpp:31:
> In file included from DerivedSources\JavaScriptCore\BytecodeStructs.h:32:
> In file included from ..\..\Source\JavaScriptCore\bytecode\BytecodeDumper.h:29:
> In file included from ..\..\Source\JavaScriptCore\bytecode/CallLinkInfo.h:31:
> In file included from ..\..\Source\JavaScriptCore\jit\PolymorphicCallStubRoutine.h:30:
> In file included from ..\..\Source\JavaScriptCore\bytecode\CallEdge.h:28:
> In file included from ..\..\Source\JavaScriptCore\bytecode/CallVariant.h:28:
> In file included from ..\..\Source\JavaScriptCore\runtime\ExecutableBaseInlines.h:28:
> In file included from ..\..\Source\JavaScriptCore\runtime/ExecutableBase.h:34:
> In file included from ..\..\Source\JavaScriptCore\bytecode\UnlinkedCodeBlock.h:34:
> In file included from ..\..\Source\JavaScriptCore\bytecode/InstructionStream.h:29:
> In file included from ..\..\Source\JavaScriptCore\bytecode/Instruction.h:28:
> ..\..\Source\JavaScriptCore\bytecode/Opcode.h(159,27): warning: adding 'unsigned int' to a string does not append to the string [-Wstring-plus-int]
>     return PADDING_STRING + PADDING_STRING_LENGTH - pad;
>            ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
> ..\..\Source\JavaScriptCore\bytecode/Opcode.h(159,27): note: use array indexing to silence this warning
>     return PADDING_STRING + PADDING_STRING_LENGTH - pad;
>                           ^
>            &              [                      ]
> 1 warning generated.


> clang version 8.0.0 (tags/RELEASE_800/final)
> Target: x86_64-pc-windows-msvc
> Thread model: posix
Comment 1 Fujii Hironori 2019-03-28 02:38:40 PDT
Created attachment 366158 [details]
Patch
Comment 2 Fujii Hironori 2019-03-28 02:41:16 PDT
I have questions.
* How to test this code?
* Is there a port enabling OPCODE_STATS?
Comment 3 Fujii Hironori 2019-03-28 02:53:12 PDT
Created attachment 366159 [details]
Patch
Comment 4 Fujii Hironori 2019-03-28 03:04:30 PDT
If define ENABLE_OPCODE_STATS 1, can't compile due to other issues.

> In file included from DerivedSources\JavaScriptCore\unified-sources\UnifiedSource-f0a787a9-8.cpp:6:
> ..\..\Source\JavaScriptCore\bytecode/Opcode.cpp(97,38): error: no template named 'pair'; did you mean 'std::pair'?
>     std::pair<int, int> leftPair = *(pair<int, int>*) left;
>                                      ^~~~
>                                      std::pair
> C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.14.26428\include\utility(93,9): note: 'std::pair' declared here
>         struct pair
>                ^
> In file included from DerivedSources\JavaScriptCore\unified-sources\UnifiedSource-f0a787a9-8.cpp:6:
> ..\..\Source\JavaScriptCore\bytecode/Opcode.cpp(99,39): error: no template named 'pair'; did you mean 'std::pair'?
>     std::pair<int, int> rightPair = *(pair<int, int>*) right;
>                                       ^~~~
>                                       std::pair
> C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.14.26428\include\utility(93,9): note: 'std::pair' declared here
>         struct pair
>                ^
> 2 errors generated.
Comment 5 Fujii Hironori 2019-03-28 03:17:07 PDT
Comment on attachment 366159 [details]
Patch

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

> Source/JavaScriptCore/bytecode/Opcode.cpp:63
> +    return &padding[stringLength - width];

out-of-bound access occurs if the opcode name is longer than width.
Comment 6 Fujii Hironori 2019-03-28 03:19:45 PDT
Created attachment 366162 [details]
Patch
Comment 7 Fujii Hironori 2019-03-28 03:25:57 PDT
(In reply to Fujii Hironori from comment #2)
> I have questions.
> * How to test this code?

Define ENABLE_OPCODE_STATS and execute jsc.exe and type "quit()".

> * Is there a port enabling OPCODE_STATS?

No.
Comment 8 Fujii Hironori 2019-03-28 18:29:54 PDT
Committed r243633: <https://trac.webkit.org/changeset/243633>
Comment 9 Radar WebKit Bug Importer 2019-03-28 18:30:56 PDT
<rdar://problem/49405319>