Most likely to avoid compiler warnings. Check whether this code provokes a warning about an empty statement:
if (foo);
If it does, then do you want the same warning in release mode for the following code?
if (foo) assert(what);
C99 (which is relevant to C++11) also says that assert
expands "to a void expression". IIRC, whitespace alone isn't an expression, even though whitespace followed by a semi-colon is an expression-statement. Good old BNF grammar.
By the way, this definition of assert
is not standard-conforming. C89 and C99 both say that when NDEBUG
is defined, then assert is defined as:
#define assert(ignore) ((void)0)
I'm not sure whether the authors consider it an important requirement, but a program could for example stringify the macro expansion and expect a particular result.