This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: fix build errors with -DNDEBUG

On 07/27/2015 12:25 AM, Paul Eggert wrote:
Martin Sebor wrote:
When glibc is compiled with -NDEBUG the
macros expand to nothing and, without the attribute or some
similar annotation, GCC complains about the variables being

That's a common problem with assert and NDEBUG.  We solve this problem
in a different way in the Emacs source code, with something like this:

# define eassert(cond) ((cond) ? (void) 0 : die (#cond, __FILE__,
# define eassert(cond) ((void) (0 && (cond)))

That way, GCC doesn't complain when assertions are disabled, because the
variables are "used" even when !ENABLE_CHECKING.  Perhaps glibc could
use a similar idea in a private macro after 2.22 is released.
(Obviously standard 'assert' can't work this way.)

Thanks, that sounds like a good suggestion for a followup patch.

You're unfortunately right that standard assert can't use this
trick. It would have been better to specify that assert doesn't
evaluate its argument when NDEBUG is defined than specifying
the implementation. But it's far too late to change that.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]