robitzki.de - Torsten Robitzki - Software-Entwicklung

Description: Blog über Software-Entwicklung / -Design

blog (30164) c++ (3790) ruby (1281) software-entwicklung (476) software-design (450)

Example domain paragraphs

In C++ ( and many other languages ), assert() is a useful function to find bugs in code during runtime. assert() tests that invariants , preconditions , or postconditions are met at runtime. Basically, assert() is used to make sure that a program is always in a valid state and to find the bug that caused the program to get into an invalid state as early as possible.

In bug-free software , an assert() will never fail and thus it's safe to remove all asserts from bug-free software. For all the mortals of us, we would usually love to keep the asserts active in the code. Just in case there is still a bug that was not caught by all the safety nets we used to get as close as possible to bug-free software.

In a so-called debug build, usually, two changes are made to the build environment: The optimizations are reduced and asserts are enabled. Both lead to larger executables. In the embedded world, this increasing executable size can easily lead to overflowing the available flash memory on the target hardware.