...
These two requirements can be counter-intuitive when expressions contain side - effects. Evaluation of the operands proceeds left-to-right, without regard to operator precedence rules and indicative parentheses; evaluation of the operators, however, obeys precedence rules and parentheses.
...
This compliant solution uses equivalent code with no side - effects. It performs only one write, to number
. The resulting expression can be reordered without concern for the evaluation order of the component expressions, making the code easier to understand and maintain.
...
Detection of all expressions involving both side - effects and also multiple operator precedence levels is straightforward. Determining the correctness of such uses is infeasible in the general case; heuristic warnings could be useful.
...
C++ Coding Standard: "EXP30-CPP. Do not depend on order of evaluation between sequence points"
Bibliography
<ac:structured-macro ac:name="unmigrated-wiki-markup |
...
" ac:schema-version="1" ac:macro-id="5dab3716-6797-4198-a5e1-39b9786bd40b"><ac:plain-text-body><![CDATA[ | [[JLS |
...
2005 |
...
AA. |
...
Bibliography#JLS |
...
05] |
...
] |
...
[§15.7, "Evaluation Order" | http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.7] |
...
]]></ac:plain-text-body></ac:structured-macro> | |
|
...
EXP07-J. Understand the differences between bitwise and logical operators 02. Expressions (EXP) EXP09-J. Do not use side-effecting expressions in assertions