Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Wiki Markup
Programmers frequently make errors regarding the precedence rules of operators due to the unintuitive low-precedence levels of {{&}}, {{\|}}, {{\^}}, {{<<}}, and {{>>}}. Mistakes regarding precedence rules can be avoided by the suitable use of parentheses. Defensive use of parentheses, if not taken to excess, also improves code readability. The precedence of operations by the order of the subclauses are defined in the Java Tutorials \[[Tutorials 2008|AA. Java References#Tutorials 08]\].

The recommendation guideline EXP09-J. Do not depend on operator precedence while using expressions containing side-effects advises against depending on parentheses for specifying the evaluation order, ; however this advice is applicable only to expressions that contain side-effects.

...

According to the operator precedence rules, the expression is parsed as the following:

Code Block
x & (MASK + OFFSET)

...

Mistakes regarding precedence rules may cause an expression to be evaluated in an unintended way. This can lead to unexpected and abnormal program behavior.

Recommendation Guideline

Severity

Likelihood

Remediation Cost

Priority

Level

EXP06- J

low

probable

medium

P4

L3

...