This is the mail archive of the
mailing list for the GCC project.
Re: Infering that the condition of a for loop is initially true?
On Mon, 18 Sep 2017, Niels Möller wrote:
> Andreas Schwab <email@example.com> writes:
> > The problem is that assert is not allowed to evaluate the expression
> > with -DNDEBUG, and side effects must not be carried out.
> I'm suggesting that with -DNDEBUG, assert(x) should let the compiler
> assume that x is true, but without producing any code to evaluate it at
There's no requirement that x is even a valid expression with -DNDEBUG.
Consider code that does
int other_variable_used_in_assertion = something ();
/* ... */
assert (other_variable_used_in_assertion == x);
where it is completely valid in ISO C not to have the NDEBUG conditional
around the assert call, because in the NDEBUG case the macro argument
won't be expanded.
Joseph S. Myers