Have a question that is bugging me a bit in regards to Precedence order. After reading the book, it says that the operator "&&" reads before "||". I understand that a bit, but was wondering if it applies when you use it for parenthesis also.
1. First set, it reads "true && false" which is "false". Then, reads "true || false" which is true. I understand this.
2. My question is here, the book says parenthesis are read first, but even following the operator precedence, is (true && false) still read before
(true || false)?
In lhs && rhs where lhs and rhs are expressions evaluated in a boolean context:
a. evaluation of lhs is sequenced before evaluation of rhs
b. short-circuit evaluation; so if lhs evaluates to false, rhs is not evaluated.
For example, where i and j are integers, evaluate: ( ++i ) && ( j = i+1 )
1. evaluate ( ++i ) (increment i)
2. if the result of the evaluation in a bool context is true (ie. i is non-zero after it is incremented),
evaluate ( j = i+1 ) (assign the value of i+1 to j)
In contrast, consider: evaluate: ( ++i ) + ( j = i+1 )
Here, the evaluations of ( ++i ) and ( j = i+1 ) are unsequenced
This results in undefined behaviour (unsequenced modification and access to scalar i)