A blog by Devendra Tewari
Programmers should use parentheses more often. The following C language snippets are mind-blowing examples of when operator precedence is not obvious and can bite you.
x & 0x01 == 0
Here, ==
is evaluated first and then &
.
a + b ^ c + d
Here, *
is evaluated first and then ^
.
SEI CERT C Coding Standard actually have rules against depending on operator precedence, for instance EXP00-C.