win64_msvc compiling breakage on unsafe use of UBool

Description

../../third_party/icu/source/i18n/dcfmtsym.cpp(332): error C2220: the following warning is treated as an error ../../third_party/icu/source/i18n/dcfmtsym.cpp(332): warning C4804: '<=': unsafe use of type 'bool' in operation [45/1658] CXX obj/third_party/icu/icui18n/dtitvinf.obj

 

here is the code

327 void resolveMissing() { 328 // For consistency with Java, this method overwrites everything with the defaults unless 329 // both beforeCurrency and afterCurrency were found in CLDR. 330 static const char* defaults[] = { "[:letter:]", "[:digit:]", " " }; 331 if (!hasBeforeCurrency || !hasAfterCurrency) { 332 for (UBool beforeCurrency = 0; beforeCurrency <= true; beforeCurrency++) { 333 for (int32_t pattern = 0; pattern < UNUM_CURRENCY_SPACING_COUNT; pattern++) { 334 dfs.setPatternForCurrencySpacing((UCurrencySpacing)pattern, 335 beforeCurrency, UnicodeString(defaults[pattern], -1, US_INV)); 336 } 337 } 338 } 339 }

the Ubool <= 0 in for loop is strange

Activity

Show:
Markus Scherer
November 18, 2022 at 10:02 PM

I see that PR #2255 is merged. Thanks for the fix!

You fixed the first problem (loop over UBool false / true) by duplicating the loop. It looks like you only need that loop once, and duplicate its body.

Frank Yung-Fong Tang
November 18, 2022 at 4:58 AM
Frank Yung-Fong Tang
November 18, 2022 at 4:27 AM

we probably also need to fix the following places

$ egrep "== true" -s -n source/*/* source/common/rbbiscan.cpp:921: if (fQuoteMode == true) { source/common/sharedobject.h:93: * If noHardReferences() == true then this object has no hard references. source/common/sharedobject.h:99: * If hasHardReferences() == true then this object has hard references. source/common/udata.cpp:571: if(checkLastFour == true && source/common/uidna.cpp:290: if(useSTD3ASCIIRules == true){ source/common/uidna.cpp:551: /*if(useSTD3ASCIIRules == true){ source/common/uidna.cpp:734: if(done == true){ source/common/uidna.cpp:832: if(done == true){ source/common/uresbund.cpp:2451: if(resB->fHasFallback == true) { source/common/uresbund.cpp:2469: else if(RES_GET_TYPE(resB->fRes) == URES_ARRAY && resB->fHasFallback == true) { source/common/uresbund.cpp:2506: if(resB->fHasFallback == true) { source/common/uresbund.cpp:2551: else if(RES_GET_TYPE(resB->fRes) == URES_ARRAY && resB->fHasFallback == true) { source/common/usprep.cpp:163: noRefCount== true) { source/common/usprep.cpp:749: if(profile->checkBiDi == true){ source/common/usprep.cpp:751: if( leftToRight == true && rightToLeft == true){ source/common/usprep.cpp:758: if( rightToLeft == true && source/common/util.cpp:305: * the quoteBuf to rule, make one final call with isLiteral == true. source/i18n/calendar.cpp:3616: if(jan1InPrevYear == true) { source/i18n/regexcmp.cpp:4068: if (c.fChar == chPound && fEOLComments == true) { source/i18n/search.cpp:84: return (m_search_->isOverlap == true ? USEARCH_ON : USEARCH_OFF); source/i18n/search.cpp:86: return (m_search_->isCanonicalMatch == true ? USEARCH_ON : source/i18n/search.cpp:245: if (m_search_->isForwardSearching == true) { source/i18n/search.cpp:298: if (m_search_->isForwardSearching == true) { source/i18n/timezone.cpp:719: // When local == true, date might not be in local standard source/i18n/timezone.cpp:724: // (and local == true), this method interprets the specified source/i18n/timezone.cpp:729: // (with 7 args) twice when local == true and DST is source/i18n/translit.cpp:443: // in the filter for this transliterator (filter.contains(ch) == true). source/i18n/tznames_impl.h:97: // >=2 values: fValues == UVector of values and fHasValuesVector == true source/i18n/usearch.cpp:822: return (strsrch->search->isOverlap == true ? USEARCH_ON : source/i18n/usearch.cpp:825: return (strsrch->search->isCanonicalMatch == true ? USEARCH_ON : source/i18n/usearch.cpp:1252: if (search->isForwardSearching == true) { source/i18n/uspoof_conf.cpp:410: U_ASSERT(fSpoofImpl->fSpoofData->fDataOwned == true); source/io/uscanf_p.cpp:326: while( ((isNotEOF = ufile_getch(input, &c)) == true) && (c == pad || u_isWhitespace(c)) ) source/io/uscanf_p.cpp:360: while( ((isNotEOF = ufile_getch(input, &c)) == true) && (count < symbolLen && c == plusSymbol[count]) ) source/io/uscanf_p.cpp:871: && ((isNotEOF = ufile_getch(input, &c)) == true) source/io/uscanf_p.cpp:962: && ((isNotEOF = ufile_getch(input, &c)) == true) source/io/uscanf_p.cpp:1265: if ( ((isNotEOF = ufile_getch32(input, &c)) == true) && uset_contains(scanset, c) ) {
Frank Yung-Fong Tang
November 18, 2022 at 4:22 AM

also

FAILED: obj/third_party/icu/icui18n/gregocal.obj ninja -t msvc -e environment.x64 -- "C:\b\s\w\ir\cache\builder\v8\third_party\depot_tools\win_toolchain\vs_files\1023ce2e82\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe" /c ../../third_party/icu/source/i18n/gregocal.cpp /Foobj/third_party/icu/icui18n/gregocal.obj /nologo /showIncludes -DU_I18N_IMPLEMENTATION -DUSE_AURA=1 -D_HAS_EXCEPTIONS=0 -D__STD_C -D_CRT_RAND_S -D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE -D_ATL_NO_OPENGL -D_WINDOWS -DCERT_CHAIN_PARA_HAS_EXTRA_FIELDS -DPSAPI_VERSION=2 -DWIN32 -D_SECURE_ATL -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -DWIN32_LEAN_AND_MEAN -DNOMINMAX -D_UNICODE -DUNICODE -DNTDDI_VERSION=NTDDI_WIN10_FE -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -D_CRT_NONSTDC_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS -DHAVE_DLOPEN=0 -DUCONFIG_ONLY_HTML_CONVERSION=1 -DUCONFIG_USE_WINDOWS_LCID_MAPPING_API=0 -DU_CHARSET_IS_UTF8=1 -D_SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DUSE_CHROMIUM_ICU=1 -DU_ENABLE_TRACING=1 -DU_ENABLE_RESOURCE_TRACING=0 -DU_STATIC_IMPLEMENTATION -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -I../.. -Igen -I../../third_party/icu/source/common -I../../third_party/icu/source/i18n /Gy /FS /bigobj /utf-8 /Zc:sizedDealloc- /wd4117 /D__DATE__= /D__TIME__= /D__TIMESTAMP__= /O1 /Ob2 /Oy- /Zc:inline /Gw /Oi /MT /wd4800 /wd4267 /WX /wd4244 /wd4005 /wd4068 /wd4267 /utf-8 /wd4244 /std:c++20 /TP /GR /Fd"obj/third_party/icu/icui18n_cc.pdb" ../../third_party/icu/source/i18n/gregocal.cpp(490): error C2220: the following warning is treated as an error ../../third_party/icu/source/i18n/gregocal.cpp(490): warning C4805: '==': unsafe mix of type 'UBool' and type 'bool' in operation
Frank Yung-Fong Tang
November 18, 2022 at 3:36 AM

also

FAILED: obj/third_party/icu/icui18n/dtitvinf.obj ninja -t msvc -e environment.x64 -- "C:\b\s\w\ir\cache\builder\v8\third_party\depot_tools\win_toolchain\vs_files\1023ce2e82\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe" /c ../../third_party/icu/source/i18n/dtitvinf.cpp /Foobj/third_party/icu/icui18n/dtitvinf.obj /nologo /showIncludes -DU_I18N_IMPLEMENTATION -DUSE_AURA=1 -D_HAS_EXCEPTIONS=0 -D__STD_C -D_CRT_RAND_S -D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE -D_ATL_NO_OPENGL -D_WINDOWS -DCERT_CHAIN_PARA_HAS_EXTRA_FIELDS -DPSAPI_VERSION=2 -DWIN32 -D_SECURE_ATL -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -DWIN32_LEAN_AND_MEAN -DNOMINMAX -D_UNICODE -DUNICODE -DNTDDI_VERSION=NTDDI_WIN10_FE -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -D_CRT_NONSTDC_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS -DHAVE_DLOPEN=0 -DUCONFIG_ONLY_HTML_CONVERSION=1 -DUCONFIG_USE_WINDOWS_LCID_MAPPING_API=0 -DU_CHARSET_IS_UTF8=1 -D_SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DUSE_CHROMIUM_ICU=1 -DU_ENABLE_TRACING=1 -DU_ENABLE_RESOURCE_TRACING=0 -DU_STATIC_IMPLEMENTATION -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -I../.. -Igen -I../../third_party/icu/source/common -I../../third_party/icu/source/i18n /Gy /FS /bigobj /utf-8 /Zc:sizedDealloc- /wd4117 /D__DATE__= /D__TIME__= /D__TIMESTAMP__= /O1 /Ob2 /Oy- /Zc:inline /Gw /Oi /MT /wd4800 /wd4267 /WX /wd4244 /wd4005 /wd4068 /wd4267 /utf-8 /wd4244 /std:c++20 /TP /GR /Fd"obj/third_party/icu/icui18n_cc.pdb" ../../third_party/icu/source/i18n/dtitvinf.cpp(507): error C2220: the following warning is treated as an error ../../third_party/icu/source/i18n/dtitvinf.cpp(507): warning C4805: '==': unsafe mix of type 'UBool' and type 'bool' in operation ../../third_party/icu/source/i18n/dtitvinf.cpp(751): warning C4805: '==': unsafe mix of type 'UBool' and type 'bool' in operation
Fixed

Details

Assignee

Reporter

Components

Priority

Time Needed

Hours

Fix versions

Created November 18, 2022 at 2:58 AM
Updated November 21, 2022 at 8:07 PM
Resolved November 21, 2022 at 8:07 PM