To assert() or not to assert(), that is not really a question...
Ravi Pokala
rpokala at freebsd.org
Mon May 28 18:08:05 UTC 2018
-----Original Message-----
From: <owner-freebsd-arch at freebsd.org> on behalf of Poul-Henning Kamp <phk at phk.freebsd.dk>
Date: 2018-05-26, Saturday at 00:19
To: <arch at freebsd.org>
Subject: To assert() or not to assert(), that is not really a question...
> ...
>
> 1. "Regular asserts" - things which are just plain wrong, which
> probably means we have a genuine bug somewhere. Examples could
> be null pointers where previous checks should have ensured this
> not be so. Also error situations for which there is no saner
> handling that killing the projcess.
>
> ...
>
> 3. "wrong asserts" - Internal state is messed up, program flow
> has taken a "impossible" branch. A good example is the
> default branch of a switch on a finite input set.
Hi Poul-Henning,
I am in strong overall agreement with your argument. I am however confused as to how (1) and (3) are different; they're both irrevocably bad internal state.
Thanks,
Ravi (rpokala@)
More information about the freebsd-arch
mailing list