Re: svn commit: r1902206 - /apr/apr/trunk/encoding/apr_base64.c

"Evgeny Kotkov via dev" <[email protected]>
Newsgroups gmane.comp.apache.apr.devel
Message-ID <CAP_GPNh-jEbXWRCFooobY7OuqCSqgRqsPEzjSHWg_oa5ZDNiBg@mail.gmail.com>
Yann Ylavic <[email protected]> writes:

> +#undef NDEBUG /* always abort() on assert()ion failure */
> +#include <assert.h>

Sorry for being late to the party, but I think there are a few problems with
the "#undef NDEBUG" line:

1) The debug implementation of an assert() may print a diagnostic message,
for example to stderr.  A caller of the library function may not be ready for
this to happen when using a non-debug version of the library.

2) The actual destination of the message seems to be implementation-defined.
For example, in Windows-based applications this may show a message box [1],
which is probably even more unexpected for the user of the library.

3) Undefining NDEBUG before other headers may silently cause unexpected
effects if any of those headers make some decisions based on the NDEBUG value,
which isn't an entirely unreasonable thing to expect.

So, depending on whether we want the checks to soft- or hard-fault, maybe we
could either remove the "#undef NDEBUG" line, or switch to a custom check that
explicitly calls an abort()?

[1] https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/assert-macro-assert-wassert#remarks


Thanks,
Evgeny Kotkov
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.