When I use the following minimal code in an C++ console application in Visual Studio 2019, I get two warnings, which are completely opposite.
int main()
{
unsigned char op1 = 0x1;
unsigned char op2 = 0x3;
unsigned char result1 = op1 | op2;
unsigned char result2 = op1 || op2;
}
The warning at unsigned char result1 = op1 | op2;
is
lnt-logical-bitwise-mismatch Using bitwise '|' when logical '||' was probably intended.
The warning at unsigned char result2 = op1 || op2;
is
lnt-logical-bitwise-mismatch Using logical '||' when bitwise '|' was probably intended.
This is a little bit curious.
My intention was to use the bitwise operator. How could I change the line unsigned char result1 = op1 | op2;
, so that the Visual Studio 2019 warning goes away?
The warning is not from the compiler; the output is error-free. Maybe it comes from the ReSharper C++ module or from Visual Studio code analysis.
(Of course I could ignore that warning, but in the original code there are a lot of them, because there a lot of unsigned char bitwise operations.)