Bug 204870

Summary: [MSVC] WebResourceLoadStatisticsStore.h is reporting warning C4804: '/': unsafe use of type 'bool' in operation
Product: WebKit Reporter: Fujii Hironori <Hironori.Fujii>
Component: WebKit2Assignee: Kate Cheney <katherine_cheney>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, darin, katherine_cheney, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=204873
Attachments:
Description Flags
Patch none

Fujii Hironori
Reported 2019-12-04 19:47:34 PST
[MSVC] WebResourceLoadStatisticsStore.h is reporting warning C4804: '/': unsafe use of type 'bool' in operation Since r253118 (Bug 203432) https://build.webkit.org/builders/WinCairo%2064-bit%20WKL%20Release%20%28Build%29/builds/13884 [18/43] Building CXX object Source\WebKit\CMakeFiles\WebKit.dir\__\__\WebKit\DerivedSources\NetworkProcessMessageReceiver.cpp.obj C:\WebKit-BuildWorker\wincairo-wkl-release\build\WebKitBuild\Release\WTF\Headers\wtf/text/IntegerToStringConversion.h(104): warning C4804: '/=': unsafe use of type 'bool' in operation C:\WebKit-BuildWorker\wincairo-wkl-release\build\WebKitBuild\Release\WTF\Headers\wtf/text/IntegerToStringConversion.h(124): note: see reference to function template instantiation 'unsigned int WTF::lengthOfNumberAsStringImpl<UnsignedIntegerType,WTF::PositiveNumber>(UnsignedIntegerType)' being compiled with [ UnsignedIntegerType=bool ] C:\WebKit-BuildWorker\wincairo-wkl-release\build\WebKitBuild\Release\WTF\Headers\wtf/text/StringConcatenateNumbers.h(58): note: see reference to function template instantiation 'unsigned int WTF::lengthOfNumberAsStringUnsigned<UnsignedInt>(UnsignedIntegerType)' being compiled with [ UnsignedInt=bool, UnsignedIntegerType=bool ] C:\WebKit-BuildWorker\wincairo-wkl-release\build\WebKitBuild\Release\WTF\Headers\wtf/text/StringConcatenateNumbers.h(58): note: while compiling class template member function 'unsigned int WTF::StringTypeAdapter<bool,void>::length(void) const' C:\WebKit-BuildWorker\wincairo-wkl-release\build\WebKitBuild\Release\WTF\Headers\wtf/text/StringConcatenate.h(319): note: see reference to function template instantiation 'unsigned int WTF::StringTypeAdapter<bool,void>::length(void) const' being compiled C:\WebKit-BuildWorker\wincairo-wkl-release\build\WebKitBuild\Release\WTF\Headers\wtf/text/StringConcatenate.h(348): note: see reference to class template instantiation 'WTF::StringTypeAdapter<bool,void>' being compiled C:\WebKit-BuildWorker\wincairo-wkl-release\build\WebKitBuild\Release\WTF\Headers\wtf/text/StringConcatenate.h(354): note: see reference to function template instantiation 'WTF::String WTF::tryMakeString<const char*,WTF::String,const char*,bool>(const char *,WTF::String,const char *,bool)' being compiled C:\WebKit-BuildWorker\wincairo-wkl-release\build\Source\WebKit\NetworkProcess\Classifier\WebResourceLoadStatisticsStore.h(87): note: see reference to function template instantiation 'WTF::String WTF::makeString<const char*,WTF::String,const char*,bool>(const char *,WTF::String,const char *,bool)' being compiled C:\WebKit-BuildWorker\wincairo-wkl-release\build\WebKitBuild\Release\WTF\Headers\wtf/text/IntegerToStringConversion.h(104): warning C4804: '/': unsafe use of type 'bool' in operation C:\WebKit-BuildWorker\wincairo-wkl-release\build\WebKitBuild\Release\WTF\Headers\wtf/text/IntegerToStringConversion.h(72): warning C4804: '%': unsafe use of type 'bool' in operation C:\WebKit-BuildWorker\wincairo-wkl-release\build\WebKitBuild\Release\WTF\Headers\wtf/text/IntegerToStringConversion.h(94): note: see reference to function template instantiation 'void WTF::writeNumberToBufferImpl<CharacterType,UnsignedIntegerType,WTF::PositiveNumber>(UnsignedIntegerType,CharacterType *)' being compiled with [ CharacterType=LChar, UnsignedIntegerType=bool ] C:\WebKit-BuildWorker\wincairo-wkl-release\build\WebKitBuild\Release\WTF\Headers\wtf/text/StringConcatenateNumbers.h(60): note: see reference to function template instantiation 'void WTF::writeNumberToBufferUnsigned<CharacterType,UnsignedInt>(UnsignedIntegerType,CharacterType *)' being compiled with [ CharacterType=LChar, UnsignedInt=bool, UnsignedIntegerType=bool ] C:\WebKit-BuildWorker\wincairo-wkl-release\build\WebKitBuild\Release\WTF\Headers\wtf/text/StringConcatenate.h(305): note: see reference to function template instantiation 'void WTF::StringTypeAdapter<bool,void>::writeTo<ResultType>(CharacterType *) const' being compiled with [ ResultType=LChar, CharacterType=LChar ] C:\WebKit-BuildWorker\wincairo-wkl-release\build\WebKitBuild\Release\WTF\Headers\wtf/text/StringConcatenate.h(305): note: see reference to function template instantiation 'void WTF::StringTypeAdapter<bool,void>::writeTo<ResultType>(CharacterType *) const' being compiled with [ ResultType=LChar, CharacterType=LChar ] C:\WebKit-BuildWorker\wincairo-wkl-release\build\WebKitBuild\Release\WTF\Headers\wtf/text/StringConcatenate.h(310): note: see reference to function template instantiation 'void WTF::stringTypeAdapterAccumulator<ResultType,WTF::StringTypeAdapter<bool,void>>(ResultType *,Adapter)' being compiled with [ ResultType=LChar, Adapter=WTF::StringTypeAdapter<bool,void> ] C:\WebKit-BuildWorker\wincairo-wkl-release\build\WebKitBuild\Release\WTF\Headers\wtf/text/StringConcatenate.h(310): note: see reference to function template instantiation 'void WTF::stringTypeAdapterAccumulator<ResultType,WTF::StringTypeAdapter<const char*,void>,WTF::StringTypeAdapter<bool,void>>(ResultType *,Adapter,WTF::StringTypeAdapter<bool,void>)' being compiled with [ ResultType=LChar, Adapter=WTF::StringTypeAdapter<const char*,void> ] C:\WebKit-BuildWorker\wincairo-wkl-release\build\WebKitBuild\Release\WTF\Headers\wtf/text/StringConcatenate.h(310): note: see reference to function template instantiation 'void WTF::stringTypeAdapterAccumulator<ResultType,WTF::StringTypeAdapter<WTF::String,void>,WTF::StringTypeAdapter<const char*,void>,WTF::StringTypeAdapter<bool,void>>(ResultType *,Adapter,WTF::StringTypeAdapter<const char*,void>,WTF::StringTypeAdapter<bool,void>)' being compiled with [ ResultType=LChar, Adapter=WTF::StringTypeAdapter<WTF::String,void> ] C:\WebKit-BuildWorker\wincairo-wkl-release\build\WebKitBuild\Release\WTF\Headers\wtf/text/StringConcatenate.h(317): note: see reference to function template instantiation 'void WTF::stringTypeAdapterAccumulator<LChar,StringTypeAdapter,WTF::StringTypeAdapter<WTF::String,void>,WTF::StringTypeAdapter<const char*,void>,WTF::StringTypeAdapter<bool,void>>(ResultType *,Adapter,WTF::StringTypeAdapter<WTF::String,void>,WTF::StringTypeAdapter<const char*,void>,WTF::StringTypeAdapter<bool,void>)' being compiled with [ StringTypeAdapter=WTF::StringTypeAdapter<const char*,void>, ResultType=LChar, Adapter=WTF::StringTypeAdapter<const char*,void> ] C:\WebKit-BuildWorker\wincairo-wkl-release\build\WebKitBuild\Release\WTF\Headers\wtf/text/StringConcatenate.h(348): note: see reference to function template instantiation 'WTF::String WTF::tryMakeStringFromAdapters<WTF::StringTypeAdapter<const char*,void>,WTF::StringTypeAdapter<WTF::String,void>,WTF::StringTypeAdapter<const char*,void>,WTF::StringTypeAdapter<bool,void>>(StringTypeAdapter,WTF::StringTypeAdapter<WTF::String,void>,WTF::StringTypeAdapter<const char*,void>,WTF::StringTypeAdapter<bool,void>)' being compiled with [ StringTypeAdapter=WTF::StringTypeAdapter<const char*,void> ] C:\WebKit-BuildWorker\wincairo-wkl-release\build\WebKitBuild\Release\WTF\Headers\wtf/text/IntegerToStringConversion.h(73): warning C4804: '/=': unsafe use of type 'bool' in operation C:\WebKit-BuildWorker\wincairo-wkl-release\build\WebKitBuild\Release\WTF\Headers\wtf/text/IntegerToStringConversion.h(73): warning C4804: '/': unsafe use of type 'bool' in operation
Attachments
Patch (1.75 KB, patch)
2019-12-05 08:47 PST, Kate Cheney
no flags
Fujii Hironori
Comment 1 2019-12-04 20:14:25 PST
This can be solved by 1. storageAccessGranted ? "0" : "1" 2. unsigned(storageAccessGranted) 3. Change makeString to explitly accept bool type #3 seems better for MSVC.
Fujii Hironori
Comment 2 2019-12-04 21:19:26 PST
GCC and Clang doesn't report warnings for bool / 10. https://godbolt.org/z/RjKz-m
Fujii Hironori
Comment 3 2019-12-04 21:57:33 PST
(In reply to Fujii Hironori from comment #1) > #3 seems better for MSVC. Filed: Bug 204873 – [MSVC] writeNumberToBufferUnsigned is unsafe for bool type
Darin Adler
Comment 4 2019-12-05 07:33:48 PST
I suggest doing (1) for now. Or could do this more efficient version: storageAccessGranted ? '0' : '1' Then I suggest we consider either adding support for bool or disabling use of bool in makeString. But I don’t think a bool should necessarily serialize as "0"/"1".
Kate Cheney
Comment 5 2019-12-05 08:47:32 PST
WebKit Commit Bot
Comment 6 2019-12-05 10:29:22 PST
Comment on attachment 384906 [details] Patch Clearing flags on attachment: 384906 Committed r253155: <https://trac.webkit.org/changeset/253155>
WebKit Commit Bot
Comment 7 2019-12-05 10:29:24 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 8 2019-12-05 10:30:20 PST
Note You need to log in before you can comment on or make changes to this bug.