Bug 23044 - Assertions with side effects
authorDodji Seketeli <dodji@redhat.com>
Wed, 9 Jan 2019 14:22:01 +0000 (15:22 +0100)
committerDodji Seketeli <dodji@redhat.com>
Wed, 9 Jan 2019 17:36:56 +0000 (18:36 +0100)
commitad8732316adeb3eea7ff8c5dba766f1898fb9e23
treee8dab9360aa534ca418fa89b999b5a1468f698fd
parent047342467ceb46bab9630820c72f4808f840b86f
Bug 23044 - Assertions with side effects

There are lots of spots in libabigail's source code where the argument
of the assert() call does have side effects.  This is a problem
because when the code is compiled with the NDEBUG macro defined, the
assert call does nothing, so the side effects of its argument are then
suppressed, changing the behaviour of the program.

To handle this issue, this patch introduces the ABG_ASSERT macro which
is a wrapper around the assert call that enable the use of side
effects in its argument.  The patch now uses that ABG_ASSERT macro
instead of using the assert call directly.

The patch also makes it so that the configure option accepts the
--disable-assert option so that the user can build libabigail with the
NDEBUG macro defined.

Tested by running the testsuite with and without the --disable-assert
option to configure.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
29 files changed:
configure.ac
include/abg-diff-utils.h
include/abg-fwd.h
src/abg-comp-filter.cc
src/abg-comparison-priv.h
src/abg-comparison.cc
src/abg-corpus-priv.h
src/abg-corpus.cc
src/abg-default-reporter.cc
src/abg-diff-utils.cc
src/abg-dwarf-reader.cc
src/abg-hash.cc
src/abg-ini.cc
src/abg-ir.cc
src/abg-leaf-reporter.cc
src/abg-reader.cc
src/abg-reporter-priv.cc
src/abg-suppression.cc
src/abg-tools-utils.cc
src/abg-workers.cc
src/abg-writer.cc
tests/test-diff-filter.cc
tests/test-diff-pkg.cc
tests/test-read-dwarf.cc
tests/test-read-write.cc
tests/test-types-stability.cc
tools/abicompat.cc
tools/abidw.cc
tools/abipkgdiff.cc