Posts: 12
Threads: 6
Joined: Aug 2013
Reputation:
0
Hello everyone,
I am having a problem with rule 12.4 (Do not use expressions with side effects in the right hand operand of a logical '&&' operator). My code is as follows:
[code]if ((DualDAC == 0) && (ADC1Flag
<t></t>
Posts: 35
Threads: 4
Joined: Sep 2004
Reputation:
0
I'm assuming that ADC1Flag has a volatile qualified type so that the act of reading its value it is a side-effect. That being the case, I think you have only two options: either nest the tests (as you did in your proposed solution), or perform the volatile access first, e.g.
[code]flag = ADC1Flag
<t></t>
Posts: 12
Threads: 6
Joined: Aug 2013
Reputation:
0
So glad I posted here, I didn't understand WHY this was happening. While it's kind of a bummer to need a nested if loop, codewise, apparently, it's the same size so it's not a huge deal. Thanks for your help!
<t></t>
Posts: 632
Threads: 18
Joined: Jan 2006
Reputation:
1
We feel that Steve has given a good response to this question and have nothing more to add.
Posted by and on behalf of the MISRA C Working Group