Skip to main content

IAR Embedded Workbench for RISC-V 3.40

MISRAC++2023-8.18.2

In this section:
Synopsis

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

Enabled by default

No

Severity/Certainty

Low/Medium

lowmedium.png
Full description

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

Coding standards
MISRA C:2012 Rule-13.4

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

MISRA C++ 2008 6-2-1

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

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