Skip to main content

IAR Embedded Workbench for RH850 3.20.x

MISRAC2012-Rule-10.2

In this section:
Synopsis

(Required) Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations.

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

Expressions of essentially character type were found used inappropriately in addition and subtraction operations.

Coding standards
MISRA C:2012 Rule-10.2

(Required) Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations

Code examples

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

void example(void) {
  char a = '9';
  char c = a + '0';
}

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

void example(void) {
  int a = 9; 
  char dig = a + '0';
}