A semicolon terminates a statement.
If your statement doesn't do anything, that's your prerogative as a programmer.
An example of a completely valid use of an empty statment:
for (int x = 0;; x++) {
if (something(x)) {
return 5;
}
if (bah(x)) {
continue;
}
if (otherthing(x)) {
return 3;
}
}
The middle statement in the for
loop is empty. But it is still necessary, as the for
loop takes three distinct statements, and the first and third are populated.
I don't see a good reason why a lone semicolon should be invalid; it does no harm. It is allowed by all relevant C/C++ standards, which is not a worse position than it not being allowed.