Skip to main content

IAR Embedded Workbench for RL78 5.20

MISRAC2012-Rule-15.6_e

In this section:
Synopsis

(Required) The body of an iteration-statement or a selection-statement shall be acompound-statement

Enabled by default

Yes

Severity/Certainty

Low/Low

lowlow.png
Full description

There are missing braces in while statements. This check is identical to MISRAC2004-14.8_d, MISRAC++2008-6-3-1_d.

Coding standards
CERT EXP19-C

Use braces for the body of an if, for, or while statement

CWE 483

Incorrect Block Delimitation

MISRA C:2004 14.8

(Required) The statement forming the body of a switch, while, do ... while, or for statement shall be a compound statement.

MISRA C:2012 Rule-15.6

(Required) The body of an iteration-statement or a selection-statement shall be acompound-statement

MISRA C++ 2008 6-3-1

(Required) The statement forming the body of a switch, while, do ... while or for statement shall be a compound statement.

Code examples

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

int example(void) {
  while (1)
    return 0;
}

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

int example(void) {
  while (1){
    return 0;
  }
}