Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with MISRA C 2012 Rule 13.5
#2
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
<t></t>


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)