Skip to main content

IAR Embedded Workbench for RH850 3.20.x

MISRAC2012-Rule-10.1_R2

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 not of essentially Boolean type, despite being interpreted as a Boolean 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 example(void) {

	int d, c, b, a;

	d = ( c & a ) && 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;

}