Skip to main content

IAR Embedded Workbench for RISC-V 3.40

MISRAC++2008-4-5-2

In this section:
Synopsis

(Required) Expressions with type enum shall not be used as operands to builtin operators other than the subscript operator [ ], the assignment operator =, the equality operators == and !=, the unary & operator, and the relational operators <, <=, >, >=.

Enabled by default

Yes

Severity/Certainty

Medium/Low

mediumlow.png
Full description

Unsafe operators are used on variables of enumeration type.

Coding standards

This check does not correspond to any coding standard rules.

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