MISRAC2012-Rule-13.4_b
In this section:
Synopsis
(Advisory) The result of an assignment operator should not be used
Enabled by default
No
Severity/Certainty
Low/Medium

Full description
Assignments were found in a sub-expression. This check is identical to MISRAC++2008-6-2-1, MISRAC++2023-8.18.2.
Coding standards
- MISRA C++ 2008 6-2-1
(Required) Assignment operators shall not be used in sub-expressions.
- MISRA C++ 2023 8.18.2
(Advisory) The result of an assignment operator should not be used
Code examples
The following code example fails the check and will give a warning:
void func()
{
int x;
int y;
int z;
x = y = z;
}
The following code example passes the check and will not give a warning about this issue:
void func()
{
int x = 2;
int y;
int z;
x = y;
x == y;
}