Share via


6281 - Incorrect order of operations

Additional information

relational operators have higher precedence than bitwise operators

 

The code has an error in operator precedence or relies on an implied order of operations.

When examining the code that is the subject of this warning, remember that relational operators (<; >; <=, >=, ==, !=) have higher precedence than bitwise operators (&; |, ^ ).

For an example, see Example 2: Implicit Order of Evaluation.

Example

The following code example elicits this warning:

    int x = 3, y = 7, z = 13;

    if (x & y != z) { ; }

The following code example avoids this warning:

    int x = 17, y = 23, z = 31;

    if ((x & y) != z) { ; }

 

 

Send comments about this topic to Microsoft

Build date: 5/3/2011