Tom Tromey <[EMAIL PROTECTED]> wrote: > Giovanni> Agreed, but my point is whether we can do that when NDEBUG > Giovanni> is defined. > > I thought when NDEBUG is defined, assert expands to something like > '(void) 0' -- the original expression is no longer around.
Yes, but the condition is still morally true in the code. NDEBUG is meant to speed up the generated code, and it's actually a pity that instead it *disables* some optimizations because we don't see the condition anymore. My suggestion is that assert with NDEBUG might expand to something like: if (condition) unreachable(); where unreachable is a function call marked with a special attribute saying that execution can never get there. This way the run-time check is removed from the code, but the range information can still be propagated and used. Notice that such an attribute would be needed in the first place for gcc_unreachable() in our own sources. Right now we expand it to gcc_assert(0), but we could do much better with a special attribute. Giovanni Bajo