6.8.3 Expression and null statements
Syntax
expression-statement:
expressionopt ;
Semantics
The expression in an expression statement is evaluated as a void expression for its side effects.[1]
A null statement (consisting of just a semicolon) performs no operations.
EXAMPLE 1
If a function call is evaluated as an expression statement for its side effects only, the discarding of its value may be made explicit by converting the expression to a void expression by means of a cast:
int p(int);
/* ... */
(void)p(0);
EXAMPLE 2
In the program fragment
char *s;
/* ... */
while (*s++ != '\0')
;
a null statement is used to supply an empty loop body to the iteration statement.
EXAMPLE 3
A null statement may also be used to carry a label just before the closing } of a compound statement.
while (loop1) {
/* ... */
while (loop2) {
/* ... */
if (want_out)
goto end_loop1;
/* ... */
}
/* ... */
end_loop1: ;
}
Forward References
Footnotes