RESOLVED FIXED 204873
[MSVC] writeNumberToBufferUnsigned is unsafe for bool type
https://bugs.webkit.org/show_bug.cgi?id=204873
Summary [MSVC] writeNumberToBufferUnsigned is unsafe for bool type
Fujii Hironori
Reported 2019-12-04 21:51:19 PST
[MSVC] writeNumberToBufferUnsigned is unsafe for bool type MSVC reports warning for using / operator for bool type. > warning C4804: '/': unsafe use of type 'bool' in operation GCC and Clang doesn't report warnings for bool / 10. https://godbolt.org/z/RjKz-m See also Bug 204870.
Attachments
Patch (3.16 KB, patch)
2019-12-04 21:56 PST, Fujii Hironori
no flags
Patch (1.64 KB, patch)
2019-12-05 19:43 PST, Fujii Hironori
no flags
Patch for landing (1.74 KB, patch)
2019-12-08 18:32 PST, Fujii Hironori
no flags
Fujii Hironori
Comment 1 2019-12-04 21:56:16 PST
Darin Adler
Comment 2 2019-12-05 07:35:08 PST
Comment on attachment 384880 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=384880&action=review I think supporting bool and turning into "0"/"1" is an accident, not intentional design. We should consider deleting the feature by disabling the template expansion instead of improving the implementation. > Source/WTF/wtf/text/IntegerToStringConversion.h:130 > + *destination++ = number ? '1' : '0'; No need for ++ here, if we decide to keep this code. > Tools/TestWebKitAPI/Tests/WTF/StringConcatenate.cpp:99 > + EXPECT_STREQ("0", makeString(false).utf8().data()); > + EXPECT_STREQ("1", makeString(true).utf8().data()); I don’t think we should serialize as "0" and "1". Instead I would suggest "false" and "true", which is what std::ostream does.
Fujii Hironori
Comment 3 2019-12-05 19:42:28 PST
Makes sense. I'm going to add static_assert at the moment.
Fujii Hironori
Comment 4 2019-12-05 19:43:35 PST
Darin Adler
Comment 5 2019-12-06 11:17:25 PST
Comment on attachment 384988 [details] Patch Looks fine. I probably would have said something more like “bool not supported” rather than focusing on the implementation detail fo why this function template won’t work
Fujii Hironori
Comment 6 2019-12-08 18:28:49 PST
I'm going to revise the message. "'bool' isn't supported"
Fujii Hironori
Comment 7 2019-12-08 18:32:42 PST
Created attachment 385129 [details] Patch for landing
Fujii Hironori
Comment 8 2019-12-09 17:55:44 PST
Comment on attachment 385129 [details] Patch for landing Clearing flags on attachment: 385129 Committed r253315: <https://trac.webkit.org/changeset/253315>
Fujii Hironori
Comment 9 2019-12-09 17:55:48 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 10 2019-12-09 17:57:15 PST
Note You need to log in before you can comment on or make changes to this bug.