18-12-2014, 08:35 PM
The C language standard basically says that (a) evaluation of logical AND and OR operators proceeds left-to-right and (b) evaluation of a logical operator stops when the result can be determined. So, when evaluating A || B, if A is true, B isn't evaluated. If evaluation of B would results in a side-effect, then that side-effect may or may not occur, depending on whether A evaluates to true or not.
I'm guessing that either or both of pacdValue1 and padcValue2 in your example are volatile-qualified, maybe because they read directly from an ADC register and therefore give rise to a side-effect when evaluated. Suppose for example that padcValue1 is volatile. The potential problem is that if padcValue1 > 4725 then padcValue1 will be evaluated twice, i.e. the register will be read twice and two side-effects will occur. But if padcValue1
I'm guessing that either or both of pacdValue1 and padcValue2 in your example are volatile-qualified, maybe because they read directly from an ADC register and therefore give rise to a side-effect when evaluated. Suppose for example that padcValue1 is volatile. The potential problem is that if padcValue1 > 4725 then padcValue1 will be evaluated twice, i.e. the register will be read twice and two side-effects will occur. But if padcValue1
<t></t>