Nóta
Aðgangur að þessari síðu krefst heimildar. Þú getur prófað aðskrá þig inn eða breyta skráasöfnum.
Aðgangur að þessari síðu krefst heimildar. Þú getur prófað að breyta skráasöfnum.
Incorrect order of operations: relational operators have higher precedence than bitwise operators
Remarks
This warning indicates a possible error in the operator precedence, which might produce incorrect results. You should check the precedence and use parentheses to clarify the intent. Relational operators (<, >, <=, >=, ==, !=) have higher precedence than bitwise operators (&, |, ^).
Code analysis name: BITWISERELATIONPRECEDENCEERROR
Example
The following code generates this warning:
#include <stdlib.h>
#define FORMAT 1
#define TYPE 2
void f(int input)
{
if (FORMAT & TYPE != input)
{
// code...
}
}
The following code uses parentheses to correct this warning:
#include <stdlib.h>
#define FORMAT 1
#define TYPE 2
void f(int input)
{
if ((FORMAT & TYPE) != input)
{
// code...
}
}