A comparison is an operand of a bitwise operator without parentheses
What it finds
flags & MASK == 0: comparisons bind tighter than &, | and ^, so this is flags & (MASK == 0), a test of the lowest bit against the result of a comparison. The bits were meant to be compared: (flags & MASK) == 0.
One operand must be a comparison written without parentheses and the other something that is not already true or false, such as another comparison: a == b & c == d combines two truth values without short-circuiting, which is done on purpose. Where & follows a name in parentheses, as in (ulong)&x, the parentheses may be a cast to a type declared in a header, and & the address operator.
From the rule's source, bitwise_precedence.rs.
Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/cpp:bitwise-precedence" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/cpp:bitwise-precedence] reason="..."tx0 explain tx0/cpp:bitwise-precedence shows the same in the terminal. Found a false positive? Report it.