Messages in this thread | | | Date | Mon, 28 Jun 1999 21:22:32 +0200 | From | Jamie Lokier <> | Subject | Re: [PATCH] *(int*)0 = 0 & variations |
| |
Riley Williams wrote: > > kassert() is a nop in release builds... > > That appears to be a contested viewpoint. The current voting is 8 > people in favour of kassert always evaluating its arguments and 6 in > favour of it not doing so if its disabled - and, as previously stated, > I'm in the latter group.
Please make that 8.99 in favour of always evaluating the argument... almost always.
Assertions should not have side effects -- if you write them right, GCC will optimise away the expression anyway. (Ignore strings for the moment).
However sometimes you'd *really* like to not evaluate the argument: occasions when you'd write `kassert (check_complex_condition ())' which calls a slow, consistency-checking function.
If they're rare putting #ifndef NDEBUG arround those calls is probably reasonable. Or just test:
kassert (defined_NDEBUG || check_complex_condition ());
enjoy, -- Jamie
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |