MISRAC++2008-6-3-1_b
In this section:
Synopsis
(Required) The statement forming the body of a switch, while, do ... while or for statement shall be a compound statement.
Enabled by default
Yes
Severity/Certainty
Low/Low

Full description
There are missing braces in for statements. This check is identical to MISRAC2004-14.8_b, MISRAC2012-Rule-15.6_b.
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
Code examples
The following code example fails the check and will give a warning:
int example(void) {
for (;;)
return 0;
}
The following code example passes the check and will not give a warning about this issue:
int example(void) {
for (;;){
return 0;
}
}