This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Infering that the condition of a for loop is initially true?
> 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
> runtime.
>
> E.g, given
>
> void foo (size_t n)
> {
> size_t i;
> assert (n < 17);
> for (i = n; i < 17; i++)
> { ... }
> }
I think what people usually do (for the folks who do it) is provide a
verify() macro that always survives. In debug builds verify() also
calls assert() to snap the debugger.
Jeff