bad_bit_mask
What it does
Checks for incompatible bit masks in comparisons.
The formula for detecting if an expression of the type _ <bit_op> m <cmp_op> c (where <bit_op> is one of {&, |} and <cmp_op> is one of {!=, >=, >, !=, >=, >}) can be determined from the following table:
table: t
Comparison Bit Op Example is always Formula
== or != & x & 2 == 3 false c & m != c
< or >= & x & 2 < 3 true m < c
or <= & x & 1 > 1 false m <= c
== or != | x | 1 == 0 false c | m != c
< or >= | x | 1 < 1 false m >= c
<= or > | x | 1 > 0 true m > c
Why is this bad?
If the bits that the comparison cares about are always set to zero or one by the bit mask, the comparison is constant true or false (depending on mask, compared value, and operators).
So the code is actively misleading, and the only reason someone would write this intentionally is to win an un