...
In this case, the programmer expects that the rightmost subexpression would to evaluate first because of the greater precedence of the operator '*' than the operator '+'. The parentheses reinforce this belief. These ideas lead to the incorrect conclusion that the right hand side will evaluate to zero whenever the get()
method returns zero. The test in the left hand subexpression should ideally reject the unprivileged user as the expected rating value is below the threshold of 10
(expecting number
= 0, due to number=get()
). Ironically, the program grants access to the unauthorized user. The reason is that evaluation of side-effect infested subexpressions follows the left to right ordering rule and should not be confused with the tenets of operator precedence, associativity and indicative parentheses.
...