Comment 40 for bug 1838448

Revision history for this message
Jonathan Wakely (jwakely) wrote :

-D_GLIBCXX_DEBUG enables the full Debug Mode for GCC's standard library:
https://gcc.gnu.org/onlinedocs/libstdc++/manual/debug_mode.html

That enables a large number of checks, but alters the class layout for all standard library containers and also changes the algorithmic complexity of some standard library algorithms, e.g. an O(log N) algorithm might become O(N) or worse. It's a very heavyweight set of checks, and affects the ABI of the compiled code.

While testing sometimes with _GLIBCXX_DEBUG defined may be valuable, it's probably not suitable for the normal debug builds and for CI testing. For a start, it would mean that a debug build is ABI-incompatible with a release build, due to the class layout changes.

The _GLIBCXX_ASSERTIONS macro defines a subset of the _GLIBCXX_DEBUG checks, with no impact on class layout and minimal impact on runtime (and no changes in algorithmic complexity). It is intended to be suitable for both debug builds and release builds. If you don't want to use it for your release builds that's fine, but it's probably the macro you want to define for regaulr debug builds and for CI testing.

N.B. defining _GLIBCXX_ASSERTIONS for other compilers is pointless, it's a macro belonging to GCC's standard library (libstdc++) and will be completely ignored by Clang's libc++ and Visual Studio's standard library.