MISRAC2004-13.1
In this section:
Synopsis
(Required) Assignment operators shall not be used in expressions that yield a boolean value.
Enabled by default
Yes
Severity/Certainty
Low/Medium

Full description
Assignment operators were found in expressions that yield a Boolean value.
Coding standards
- MISRA C:2004 13.1
(Required) Assignment operators shall not be used in expressions that yield a boolean value.
Code examples
The following code example fails the check and will give a warning:
void example(void) {
int result;
if (result = condition()) {
}
}
The following code example passes the check and will not give a warning about this issue:
void example(void) {
int result = condition();
if (result) {
}
}