Skip to main content

IAR Embedded Workbench for Arm 9.70.x

MISRAC2012-Rule-10.1_R3

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 was found that is of essentially Boolean type, despite being interpreted as a numeric value.

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:

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

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

typedef char	boolean_t;	/* Compliant: Boolean-by-enforcement */

void example(void)
{
    boolean_t d;
    boolean_t c = 1;
    boolean_t b = 0;
    boolean_t a = 1;

    d = ( c && a ) && b;

}
void func()
{
  bool x;
  bool y;
  y = x && y;
}