Le 4 sept. 09 à 03:23, Eric Blake a écrit :
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Joel E. Denny on 9/3/2009 12:08 PM:
+ assert(i <= sizeof argv / sizeof *argv);
}
/* <assert.h>'s assertions are too heavyweight, and can be disabled
too easily, so use aver rather than assert. */
I don't have a strong opinion on this issue, but we ought to
consider it.
Any reason not to continue with his approach?
Fine with me to change that. The coreutils package now uses more
asserts
than back when Paul gave his opinion 3 years ago, but it also uses the
gnulib module assert which makes it very easy to call ./configure
- --disable-asserts, which, like you said, disables all asserts
rather easily.
I feel uncomfortable with the fact that aver is silent, so I'd prefer
that aver == assert in !NDEBUG mode, and becomes the original aver
implementation otherwise. Something like:
/* <assert.h>'s assertions are heavyweight and can be disabled too
easily, but deliver more information on failure. So use aver. See
discussions at
<http://lists.gnu.org/archive/html/bison-patches/2006-01/msg00080.html
>
<http://lists.gnu.org/archive/html/bison-patches/2006-09/msg00111.html
>.
*/
#if defined NDEBUG
static inline void
aver (bool assertion)
{
if (! assertion)
abort ();
}
#else
# include <assert.h>
# define aver assert
#endif