Skip to main content

IAR Embedded Workbench for RH850 3.20.x

MISRAC++2008-7-2-1

In this section:
Synopsis

(Required) An expression with enum underlying type shall only have values corresponding to the enumerators of the enumeration.

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

There are conversions to enum type that are out of range of the enumeration. This check is identical to ENUM-bounds.

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 example(void)
{
  ens one = (ens)10;
}

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

enum ens { ONE, TWO, THREE };

void example(void)
{
  ens one = ONE;
  ens two = TWO;
  two = one;
}