<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>ChapterΒ 30.Β Debug Mode</title><meta name="generator" content="DocBook XSL Stylesheets V1.74.0" /><meta name="keywords" content=" C++ , library , debug " /><meta name="keywords" content=" ISO C++ , library " /><link rel="home" href="../spine.html" title="The GNU C++ Library Documentation" /><link rel="up" href="extensions.html" title="PartΒ XII.Β Extensions" /><link rel="prev" href="ext_compile_checks.html" title="ChapterΒ 29.Β Compile Time Checks" /><link rel="next" href="bk01pt12ch30s02.html" title="Semantics" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">ChapterΒ 30.Β Debug Mode</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ext_compile_checks.html">Prev</a>Β </td><th width="60%" align="center">PartΒ XII.ΒExtensions</th><td width="20%" align="right">Β <a accesskey="n" href="bk01pt12ch30s02.html">Next</a></td></tr></table><hr /></div><div class="chapter" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="manual.ext.debug_mode"></a>ChapterΒ 30.Β Debug Mode</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="debug_mode.html#manual.ext.debug_mode.intro">Intro</a></span></dt><dt><span class="sect1"><a href="bk01pt12ch30s02.html">Semantics</a></span></dt><dt><span class="sect1"><a href="bk01pt12ch30s03.html">Using</a></span></dt><dd><dl><dt><span class="sect2"><a href="bk01pt12ch30s03.html#debug_mode.using.mode">Using the Debug Mode</a></span></dt><dt><span class="sect2"><a href="bk01pt12ch30s03.html#debug_mode.using.specific">Using a Specific Debug Container</a></span></dt></dl></dd><dt><span class="sect1"><a href="bk01pt12ch30s04.html">Design</a></span></dt><dd><dl><dt><span class="sect2"><a href="bk01pt12ch30s04.html#manual.ext.debug_mode.design.goals">Goals</a></span></dt><dt><span class="sect2"><a href="bk01pt12ch30s04.html#manual.ext.debug_mode.design.methods">Methods</a></span></dt><dt><span class="sect2"><a href="bk01pt12ch30s04.html#manual.ext.debug_mode.design.other">Other Implementations</a></span></dt></dl></dd></dl></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="manual.ext.debug_mode.intro"></a>Intro</h2></div></div></div><p>By default, libstdc++ is built with efficiency in mind, andtherefore performs little or no error checking that is notrequired by the C++ standard. This means that programs thatincorrectly use the C++ standard library will exhibit behaviorthat is not portable and may not even be predictable, because theytread into implementation-specific or undefined behavior. Todetect some of these errors before they can become problematic,libstdc++ offers a debug mode that provides additional checking oflibrary facilities, and will report errors in the use of libstdc++as soon as they can be detected by emitting a description of theproblem to standard error and aborting the program. This debugmode is available with GCC 3.4.0 and later versions.</p><p>The libstdc++ debug mode performs checking for many areas of theC++ standard, but the focus is on checking interactions amongstandard iterators, containers, and algorithms, including:</p><div class="itemizedlist"><ul type="disc"><li><p><span class="emphasis"><em>Safe iterators</em></span>: Iterators keep track of thecontainer whose elements they reference, so errors such asincrementing a past-the-end iterator or dereferencing an iteratorthat points to a container that has been destructed are diagnosedimmediately.</p></li><li><p><span class="emphasis"><em>Algorithm preconditions</em></span>: Algorithms attempt tovalidate their input parameters to detect errors as early aspossible. For instance, the <code class="code">set_intersection</code>algorithm requires that its iteratorparameters <code class="code">first1</code> and <code class="code">last1</code> form a validiterator range, and that the sequence[<code class="code">first1</code>, <code class="code">last1</code>) is sorted according tothe same predicate that was passedto <code class="code">set_intersection</code>; the libstdc++ debug mode willdetect an error if the sequence is not sorted or was sorted by adifferent predicate.</p></li></ul></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ext_compile_checks.html">Prev</a>Β </td><td width="20%" align="center"><a accesskey="u" href="extensions.html">Up</a></td><td width="40%" align="right">Β <a accesskey="n" href="bk01pt12ch30s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ChapterΒ 29.Β Compile Time ChecksΒ </td><td width="20%" align="center"><a accesskey="h" href="../spine.html">Home</a></td><td width="40%" align="right" valign="top">Β Semantics</td></tr></table></div></body></html>