![]() |
|
MISRA-C:2004 Rule 13.1: (Required) |
|
||||
![]() | |||||||
If assignments are required in the operands of a Boolean-valued expression then they must be performed separately outside of those operands. This helps to avoid getting '=' and '==' confused, and assists the static detection of mistakes.
See 'Boolean expressions' in the glossary.
For example write:
x=y;if(x!=0){foo();}
and not:
if((x=y)!=0)/* Boolean by context */{foo();}
or even worse:
if(x=y){foo();}
QAC messages that encompass this guideline:
| 3326 | The result of an assignment is being used in a logical operation. |
|
||
(c) The Motor Industry Research Association, 2004
|
QA C Source Code Analyser 8.1.2
MISRA-C:2004 Compliance Module 3.2 © 2013 Programming Research www.programmingresearch.com |
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index | Contents |