libstdc++: Enable _GLIBCXX_ASSERTIONS by default for -O0 [PR112808]
commit361d230fd7800a7e749aba8ed020f54f5c26d504
authorJonathan Wakely <jwakely@redhat.com>
Thu, 26 Sep 2024 15:55:07 +0000 (26 16:55 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 9 Oct 2024 12:39:16 +0000 (9 13:39 +0100)
treeaa237d273949733bd26601e567893b541ecb91e3
parent6ce1df379a64439ea429b6c5834e9f853d520112
libstdc++: Enable _GLIBCXX_ASSERTIONS by default for -O0 [PR112808]

Too many users don't know about -D_GLIBCXX_ASSERTIONS and so are missing
valuable checks for C++ standard library preconditions. This change
enables libstdc++ assertions by default when compiling with -O0 so that
we diagnose more bugs by default.

When users enable optimization we don't add the assertions by default
(because they have non-zero overhead) so they still need to enable them
manually.

For users who really don't want the assertions even in unoptimized
builds, defining _GLIBCXX_NO_ASSERTIONS will prevent them from being
enabled automatically.

libstdc++-v3/ChangeLog:

PR libstdc++/112808
* doc/xml/manual/using.xml (_GLIBCXX_ASSERTIONS): Document
implicit definition for -O0 compilation.
(_GLIBCXX_NO_ASSERTIONS): Document.
* doc/html/manual/using_macros.html: Regenerate.
* include/bits/c++config [!__OPTIMIZE__] (_GLIBCXX_ASSERTIONS):
Define for unoptimized builds.
libstdc++-v3/doc/html/manual/using_macros.html
libstdc++-v3/doc/xml/manual/using.xml
libstdc++-v3/include/bits/c++config