Skip to main content

IAR Embedded Workbench for RL78 5.20

MISRAC2012-Rule-10.1_R5

In this section:
Synopsis

(Required) Operands shall not be of an inappropriate essential type.

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

An operand that is of essentially enum type is used in an arithmetic operation, because an enum object uses an implementation-defined integer type.

Coding standards
MISRA C:2012 Rule-10.1

(Required) Operands shall not be of an inappropriate essential type

Code examples

The following code example fails the check and will give a warning:

enum ens { ONE, TWO, THREE };

void func(ens b)
{
  ens x;
  bool y;
  y = x | b;
}

The following code example passes the check and will not give a warning about this issue:

enum ens { ONE, TWO, THREE };

void func(ens b)
{
  ens y;
  y = b;
}