[1] The classic gotcha in C/C++ is the construct It is syntactically valid: it puts the value of b into a and then executes code if a is non-zero.
However most commonly it is a typo: the programmer probably meant which executes code if a and b are equal.
[1] Modern compilers will usually generate a warning when encountering the former construct (conditional branch on assignment, not comparison), depending on compiler options (e.g., the -Wall option for gcc).
To avoid this gotcha, some programming languages such include specific syntax for when this is desired behavior, such as Python's "walrus" operator (:=).
In languages where this specific syntax does not exist, there is a recommendation[2] to keep the constants in the left side of the comparison, e.g. 42 == x rather than x == 42.