GNUTLS_ASSERT macro

Nikos Mavrogiannopoulos nmav at gnutls.org
Fri Nov 26 18:19:16 CET 2010


On Fri, Nov 26, 2010 at 4:08 PM, Jeffrey Walton <noloader at gmail.com> wrote:
> Hi All,
> A properly asserted program expedites finding the point of first
> failure in a program or library. I believe the current GnuTLS assert
> could be improved.

gnutls_assert() is not related to the use of assert(). The name might
be confusing, but it's already there. We use gnutls_assert() to get an
easy backtrace of a program that fails without going through the debugger.

There is run-time functionality to enable assertions and print information
on them.

> Typically, and application or library is built with either a "debug"
> configuration, or a "release" configuration. The current assert is
> gnutls_assert(), which does nothing when DEBUG is defined.

It's not related to how assert() works.

> GnuTLS should probably honor the intent of standard assert() and
> provide equivalent behavior: if NDEBUG is defined, asserts are not
> compiled into the program code. Otherwise, asserts are compiled into
> the program code [1].

No. The original assert() is very dangerous, and pretty useless to me.
Projects that need assertions why wouldn't they use them in production
code? The cost of the instructions of the "if" is pretty low to even
consider it.

regards,
Nikos




More information about the Gnutls-devel mailing list