This is described in more detail in
<a class="link" href="ext_compile_checks.html" title="Chapter 16. Compile Time Checks">Compile Time Checks</a>.
</p></dd><dt><span class="term"><code class="code">_GLIBCXX_ASSERTIONS</code></span></dt><dd><p>
- Undefined by default. When defined, enables extra error checking in
- the form of precondition assertions, such as bounds checking in
- strings and null pointer checks when dereferencing smart pointers.
+ Defined by default when compiling with no optimization, undefined
+ by default when compiling with optimization.
+ When defined, enables extra error checking in the form of
+ precondition assertions, such as bounds checking in strings
+ and null pointer checks when dereferencing smart pointers.
+ </p></dd><dt><span class="term"><code class="code">_GLIBCXX_NO_ASSERTIONS</code></span></dt><dd><p>
+ Undefined by default. When defined, prevents the implicit
+ definition of <code class="code">_GLIBCXX_ASSERTIONS</code> when compiling
+ with no optimization.
</p></dd><dt><span class="term"><code class="code">_GLIBCXX_DEBUG</code></span></dt><dd><p>
Undefined by default. When defined, compiles user code using
the <a class="link" href="debug_mode.html" title="Chapter 17. Debug Mode">debug mode</a>.
<varlistentry><term><code>_GLIBCXX_ASSERTIONS</code></term>
<listitem>
<para>
- Undefined by default. When defined, enables extra error checking in
- the form of precondition assertions, such as bounds checking in
- strings and null pointer checks when dereferencing smart pointers.
+ Defined by default when compiling with no optimization, undefined
+ by default when compiling with optimization.
+ When defined, enables extra error checking in the form of
+ precondition assertions, such as bounds checking in strings
+ and null pointer checks when dereferencing smart pointers.
+ </para>
+ </listitem></varlistentry>
+ <varlistentry><term><code>_GLIBCXX_NO_ASSERTIONS</code></term>
+ <listitem>
+ <para>
+ Undefined by default. When defined, prevents the implicit
+ definition of <code>_GLIBCXX_ASSERTIONS</code> when compiling
+ with no optimization.
</para>
</listitem></varlistentry>
<varlistentry><term><code>_GLIBCXX_DEBUG</code></term>
#pragma GCC visibility pop
}
+#ifndef _GLIBCXX_ASSERTIONS
+# if defined(_GLIBCXX_DEBUG)
// Debug Mode implies checking assertions.
-#if defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_ASSERTIONS)
-# define _GLIBCXX_ASSERTIONS 1
+# define _GLIBCXX_ASSERTIONS 1
+# elif ! defined(__OPTIMIZE__) && ! defined(_GLIBCXX_NO_ASSERTIONS)
+// Enable assertions for unoptimized builds.
+# define _GLIBCXX_ASSERTIONS 1
+# endif
#endif
// Disable std::string explicit instantiation declarations in order to assert.