8.8.2 The do statement
do statement conditionally executes an embedded statement one or more times.
- do embedded-statement while ( boolean-expression ) ;
do statement is executed as follows:
- Control is transferred to the embedded statement.
- When and if control reaches the end point of the embedded statement (possibly from execution of a
continuestatement), the boolean-expression (Section 7.16) is evaluated. If the Boolean expression yields
true, control is transferred to the beginning of the
dostatement. Otherwise, control is transferred to the end point of the
Within the embedded statement of a
do statement, a
break statement (Section 8.9.1) may be used to transfer control to the end point of the
do statement (thus ending iteration of the embedded statement), and a
continue statement (Section 8.9.2) may be used to transfer control to the end point of the embedded statement (thus performing another iteration of the
The embedded statement of a
do statement is reachable if the
do statement is reachable.
The end point of a
do statement is reachable if at least one of the following is true:
dostatement contains a reachable
breakstatement that exits the
- The end point of the embedded statement is reachable and the Boolean expression does not have the constant value