From 4f5684533bb317184dc85e8152a0aeb9c157e97c Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Mon, 11 Apr 2022 13:57:40 -0400 Subject: [PATCH] Use logical and for boolean operation in bstr This seems like a mistake and recent versions of clang even complain about it: /runtime/src/coreclr/palrt/bstr.cpp:50:13: error: use of bitwise '&' with boolean operands [-Werror,-Wbitwise-instead-of-logical] if (SUCCEEDED(ULongMult(cchSize, sizeof(WCHAR), &temp)) & ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ && /runtime/src/coreclr/pal/inc/pal.h:5144:27: note: expanded from macro 'SUCCEEDED' #define SUCCEEDED(Status) ((HRESULT)(Status) >= 0) ^ /runtime/src/coreclr/palrt/bstr.cpp:50:13: note: cast one or both operands to int to silence this warning /runtime/src/coreclr/pal/inc/pal.h:5144:27: note: expanded from macro 'SUCCEEDED' #define SUCCEEDED(Status) ((HRESULT)(Status) >= 0) ^ 1 error generated. --- src/coreclr/palrt/bstr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/palrt/bstr.cpp b/src/coreclr/palrt/bstr.cpp index 2f5ccd9cd48075..93c1da77430639 100644 --- a/src/coreclr/palrt/bstr.cpp +++ b/src/coreclr/palrt/bstr.cpp @@ -47,7 +47,7 @@ inline HRESULT CbSysStringSize(ULONG cchSize, BOOL isByteLen, ULONG *result) else { ULONG temp = 0; // should not use in-place addition in ULongAdd - if (SUCCEEDED(ULongMult(cchSize, sizeof(WCHAR), &temp)) & + if (SUCCEEDED(ULongMult(cchSize, sizeof(WCHAR), &temp)) && SUCCEEDED(ULongAdd(temp, constant, result))) { *result = *result & ~WIN32_ALLOC_ALIGN;