Re: [PATCH] *(int*)0 = 0 & variations

Jeff Garzik (jgarzik@pobox.com)
Wed, 23 Jun 1999 19:39:18 -0400


Manfred Spraul wrote:
>
> From: adve@oce.nl (Arjan van de Ven):
> > #define kassert(cond) if (cond) ;
> >
> > That way,kassert(var++)works the same with and without
> > DEBUG. (I know, one shouldn't change a variable in an
> > assert, but there is NO decent way to find such bugs)
>
> I disagree:
> * all kassert() makros will be new, so we won't have a legacy code/
> overlooked change problem
> * is possible that kassert() calls functions which should only be called in
> debug, so "if(cond)" would be a slowdown.
> * [UGLY] we could add the VERIFY() macro, that's what Microsoft did in MFC.
>
> --> IMHO the best solution:
> + kassert() identical to the normal user mode assert(). It _does not_ oops.

Reading from my ANSI C reference:

assert checks the value of the given expression. If the expression is
false (zero), assert prints a message into the standard error stream
and
calls abort.

Looking at /usr/include/assert.h verifies this. assert() always calls
abort() and always has. It certainly makes sense to have an assert
macro that does not abort, but it is incorrect to claim that the normal
assert does not kill the program.

Jeff

-
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/