Skip to main content

IAR Embedded Workbench for RL78 5.20

MISRAC++2008-6-2-1

In this section:
Synopsis

(Required) Assignment operators shall not be used in sub-expressions.

Enabled by default

Yes

Severity/Certainty

Low/Medium

lowmedium.png
Full description

One or more assignment operators are used in sub-expressions. This check is identical to MISRAC2012-Rule-13.4_b, MISRAC++2023-8.18.2.

Coding standards
MISRA C:2012 Rule-13.4

(Advisory) The result of an assignment operator should not be used

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;
}