[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH COMMITTED] src: Fix NDEBUG compilation: avoid side-effects in
From: |
Dan Čermák |
Subject: |
Re: [PATCH COMMITTED] src: Fix NDEBUG compilation: avoid side-effects in assert |
Date: |
Thu, 27 Feb 2020 09:48:02 +0100 |
address@hidden (Jose E. Marchesi) writes:
>
> on a related note: how about re-defining `assert` to `(void)(cond)` for
> NDEBUG builds, so that we don't get a plethora of unused variable
> warnings now?
>
> Hm, is that common practice? It seems to me that if a given variable is
> only used in an assert, we probably want to identify it so we can
> rewrite the code to avoid that situation.
Usually not automatically, but I've seen the pattern:
#ifdef NDEBUG
UNUSED(val);
#else
assert(val);
#endif
just far too often.
>
> Also, are NDEBUG builds actually a good idea? I recall that when fuzzing
> poke a lot of "crashes" that I found were just failed assertions. So
> maybe we should refrain from supporting NDEBUG builds for now?
>
> Well, we are not "supporting" NDEBUG, meaning no build mode of poke
> AC_DEFINEs NDEBUG.
Good! I'm not a fan of NDEBUG builds anyway. The security loss is imho
not worth the (usually negligible) performance gain.
signature.asc
Description: PGP signature