Commit 01b3b9e3 by Jonathan Wakely Committed by Jonathan Wakely

Update libstdc++ documentation for Support and Diagnostics clauses

	* doc/xml/manual/diagnostics.xml: Update list of headers that define
	exception classes.
	* doc/xml/manual/support.xml: Rewrite advice around NULL. Rewrite
	section about new/delete overloads. Improve section on verbose
	terminate handler.
	* doc/html/*: Regenerate.

From-SVN: r271782
parent 30f78ec7
2019-05-30 Jonathan Wakely <jwakely@redhat.com> 2019-05-30 Jonathan Wakely <jwakely@redhat.com>
* doc/xml/manual/diagnostics.xml: Update list of headers that define
exception classes.
* doc/xml/manual/support.xml: Rewrite advice around NULL. Rewrite
section about new/delete overloads. Improve section on verbose
terminate handler.
* doc/html/*: Regenerate.
* doc/xml/manual/status_cxx2020.xml: Add feature-test macro for * doc/xml/manual/status_cxx2020.xml: Add feature-test macro for
P0811R3. Change status of P1353R0. P0811R3. Change status of P1353R0.
* doc/html/*: Regenerate. * doc/html/*: Regenerate.
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
</a></span></dt><dd><dl><dt><span class="chapter"><a href="manual/support.html">4. </a></span></dt><dd><dl><dt><span class="chapter"><a href="manual/support.html">4.
Support Support
</a></span></dt><dd><dl><dt><span class="section"><a href="manual/support.html#std.support.types">Types</a></span></dt><dd><dl><dt><span class="section"><a href="manual/support.html#std.support.types.fundamental">Fundamental Types</a></span></dt><dt><span class="section"><a href="manual/support.html#std.support.types.numeric_limits">Numeric Properties</a></span></dt><dt><span class="section"><a href="manual/support.html#std.support.types.null">NULL</a></span></dt></dl></dd><dt><span class="section"><a href="manual/dynamic_memory.html">Dynamic Memory</a></span></dt><dt><span class="section"><a href="manual/termination.html">Termination</a></span></dt><dd><dl><dt><span class="section"><a href="manual/termination.html#support.termination.handlers">Termination Handlers</a></span></dt><dt><span class="section"><a href="manual/termination.html#support.termination.verbose">Verbose Terminate Handler</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="manual/diagnostics.html">5. </a></span></dt><dd><dl><dt><span class="section"><a href="manual/support.html#std.support.types">Types</a></span></dt><dd><dl><dt><span class="section"><a href="manual/support.html#std.support.types.fundamental">Fundamental Types</a></span></dt><dt><span class="section"><a href="manual/support.html#std.support.types.numeric_limits">Numeric Properties</a></span></dt><dt><span class="section"><a href="manual/support.html#std.support.types.null">NULL</a></span></dt></dl></dd><dt><span class="section"><a href="manual/dynamic_memory.html">Dynamic Memory</a></span></dt><dd><dl><dt><span class="section"><a href="manual/dynamic_memory.html#std.support.memory.notes">Additional Notes</a></span></dt></dl></dd><dt><span class="section"><a href="manual/termination.html">Termination</a></span></dt><dd><dl><dt><span class="section"><a href="manual/termination.html#support.termination.handlers">Termination Handlers</a></span></dt><dt><span class="section"><a href="manual/termination.html#support.termination.verbose">Verbose Terminate Handler</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="manual/diagnostics.html">5.
Diagnostics Diagnostics
</a></span></dt><dd><dl><dt><span class="section"><a href="manual/diagnostics.html#std.diagnostics.exceptions">Exceptions</a></span></dt><dd><dl><dt><span class="section"><a href="manual/diagnostics.html#std.diagnostics.exceptions.api">API Reference</a></span></dt><dt><span class="section"><a href="manual/diagnostics.html#std.diagnostics.exceptions.data">Adding Data to <code class="classname">exception</code></a></span></dt></dl></dd><dt><span class="section"><a href="manual/errno.html">Use of errno by the library</a></span></dt><dt><span class="section"><a href="manual/concept_checking.html">Concept Checking</a></span></dt></dl></dd><dt><span class="chapter"><a href="manual/utilities.html">6. </a></span></dt><dd><dl><dt><span class="section"><a href="manual/diagnostics.html#std.diagnostics.exceptions">Exceptions</a></span></dt><dd><dl><dt><span class="section"><a href="manual/diagnostics.html#std.diagnostics.exceptions.api">API Reference</a></span></dt><dt><span class="section"><a href="manual/diagnostics.html#std.diagnostics.exceptions.data">Adding Data to <code class="classname">exception</code></a></span></dt></dl></dd><dt><span class="section"><a href="manual/errno.html">Use of errno by the library</a></span></dt><dt><span class="section"><a href="manual/concept_checking.html">Concept Checking</a></span></dt></dl></dd><dt><span class="chapter"><a href="manual/utilities.html">6.
......
...@@ -8,20 +8,32 @@ ...@@ -8,20 +8,32 @@
Diagnostics Diagnostics
<a id="id-1.3.4.3.1.1.1" class="indexterm"></a> <a id="id-1.3.4.3.1.1.1" class="indexterm"></a>
</h2></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="section"><a href="diagnostics.html#std.diagnostics.exceptions">Exceptions</a></span></dt><dd><dl><dt><span class="section"><a href="diagnostics.html#std.diagnostics.exceptions.api">API Reference</a></span></dt><dt><span class="section"><a href="diagnostics.html#std.diagnostics.exceptions.data">Adding Data to <code class="classname">exception</code></a></span></dt></dl></dd><dt><span class="section"><a href="errno.html">Use of errno by the library</a></span></dt><dt><span class="section"><a href="concept_checking.html">Concept Checking</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="std.diagnostics.exceptions"></a>Exceptions</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="std.diagnostics.exceptions.api"></a>API Reference</h3></div></div></div><p> </h2></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="section"><a href="diagnostics.html#std.diagnostics.exceptions">Exceptions</a></span></dt><dd><dl><dt><span class="section"><a href="diagnostics.html#std.diagnostics.exceptions.api">API Reference</a></span></dt><dt><span class="section"><a href="diagnostics.html#std.diagnostics.exceptions.data">Adding Data to <code class="classname">exception</code></a></span></dt></dl></dd><dt><span class="section"><a href="errno.html">Use of errno by the library</a></span></dt><dt><span class="section"><a href="concept_checking.html">Concept Checking</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="std.diagnostics.exceptions"></a>Exceptions</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="std.diagnostics.exceptions.api"></a>API Reference</h3></div></div></div><p>
All exception objects are defined in one of the standard header Most exception classes are defined in one of the standard headers
files: <code class="filename">exception</code>, <code class="filename">&lt;exception&gt;</code>,
<code class="filename">stdexcept</code>, <code class="filename">new</code>, and <code class="filename">&lt;stdexcept&gt;</code>,
<code class="filename">typeinfo</code>. <code class="filename">&lt;new&gt;</code>, and
<code class="filename">&lt;typeinfo&gt;</code>.
The C++ 2011 revision of the standard added more exception types
in the headers
<code class="filename">&lt;functional&gt;</code>,
<code class="filename">&lt;future&gt;</code>,
<code class="filename">&lt;regex&gt;</code>, and
<code class="filename">&lt;system_error&gt;</code>.
The C++ 2017 revision of the standard added more exception types
in the headers
<code class="filename">&lt;any&gt;</code>,
<code class="filename">&lt;filesystem&gt;</code>,
<code class="filename">&lt;optional&gt;</code>, and
<code class="filename">&lt;variant&gt;</code>.
</p><p> </p><p>
The base exception object is <code class="classname">exception</code>, All exceptions thrown by the library have a base class of type
located in <code class="filename">exception</code>. This object has no <code class="classname">std::exception</code>,
<code class="classname">string</code> member. defined in <code class="filename">&lt;exception&gt;</code>.
This type has no <code class="classname">std::string</code> member.
</p><p> </p><p>
Derived from this are several classes that may have a Derived from this are several classes that may have a
<code class="classname">string</code> member: a full hierarchy can be <code class="classname">std::string</code> member. A full hierarchy can be
found in the source documentation. found in the source documentation.
</p><p>
Full API details.
</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="std.diagnostics.exceptions.data"></a>Adding Data to <code class="classname">exception</code></h3></div></div></div><p> </p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="std.diagnostics.exceptions.data"></a>Adding Data to <code class="classname">exception</code></h3></div></div></div><p>
The standard exception classes carry with them a single string as The standard exception classes carry with them a single string as
data (usually describing what went wrong or where the 'throw' took data (usually describing what went wrong or where the 'throw' took
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
</a></span></dt><dd><dl><dt><span class="chapter"><a href="support.html">4. </a></span></dt><dd><dl><dt><span class="chapter"><a href="support.html">4.
Support Support
</a></span></dt><dd><dl><dt><span class="section"><a href="support.html#std.support.types">Types</a></span></dt><dd><dl><dt><span class="section"><a href="support.html#std.support.types.fundamental">Fundamental Types</a></span></dt><dt><span class="section"><a href="support.html#std.support.types.numeric_limits">Numeric Properties</a></span></dt><dt><span class="section"><a href="support.html#std.support.types.null">NULL</a></span></dt></dl></dd><dt><span class="section"><a href="dynamic_memory.html">Dynamic Memory</a></span></dt><dt><span class="section"><a href="termination.html">Termination</a></span></dt><dd><dl><dt><span class="section"><a href="termination.html#support.termination.handlers">Termination Handlers</a></span></dt><dt><span class="section"><a href="termination.html#support.termination.verbose">Verbose Terminate Handler</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="diagnostics.html">5. </a></span></dt><dd><dl><dt><span class="section"><a href="support.html#std.support.types">Types</a></span></dt><dd><dl><dt><span class="section"><a href="support.html#std.support.types.fundamental">Fundamental Types</a></span></dt><dt><span class="section"><a href="support.html#std.support.types.numeric_limits">Numeric Properties</a></span></dt><dt><span class="section"><a href="support.html#std.support.types.null">NULL</a></span></dt></dl></dd><dt><span class="section"><a href="dynamic_memory.html">Dynamic Memory</a></span></dt><dd><dl><dt><span class="section"><a href="dynamic_memory.html#std.support.memory.notes">Additional Notes</a></span></dt></dl></dd><dt><span class="section"><a href="termination.html">Termination</a></span></dt><dd><dl><dt><span class="section"><a href="termination.html#support.termination.handlers">Termination Handlers</a></span></dt><dt><span class="section"><a href="termination.html#support.termination.verbose">Verbose Terminate Handler</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="diagnostics.html">5.
Diagnostics Diagnostics
</a></span></dt><dd><dl><dt><span class="section"><a href="diagnostics.html#std.diagnostics.exceptions">Exceptions</a></span></dt><dd><dl><dt><span class="section"><a href="diagnostics.html#std.diagnostics.exceptions.api">API Reference</a></span></dt><dt><span class="section"><a href="diagnostics.html#std.diagnostics.exceptions.data">Adding Data to <code class="classname">exception</code></a></span></dt></dl></dd><dt><span class="section"><a href="errno.html">Use of errno by the library</a></span></dt><dt><span class="section"><a href="concept_checking.html">Concept Checking</a></span></dt></dl></dd><dt><span class="chapter"><a href="utilities.html">6. </a></span></dt><dd><dl><dt><span class="section"><a href="diagnostics.html#std.diagnostics.exceptions">Exceptions</a></span></dt><dd><dl><dt><span class="section"><a href="diagnostics.html#std.diagnostics.exceptions.api">API Reference</a></span></dt><dt><span class="section"><a href="diagnostics.html#std.diagnostics.exceptions.data">Adding Data to <code class="classname">exception</code></a></span></dt></dl></dd><dt><span class="section"><a href="errno.html">Use of errno by the library</a></span></dt><dt><span class="section"><a href="concept_checking.html">Concept Checking</a></span></dt></dl></dd><dt><span class="chapter"><a href="utilities.html">6.
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
</h1></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="chapter"><a href="support.html">4. </h1></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="chapter"><a href="support.html">4.
Support Support
</a></span></dt><dd><dl><dt><span class="section"><a href="support.html#std.support.types">Types</a></span></dt><dd><dl><dt><span class="section"><a href="support.html#std.support.types.fundamental">Fundamental Types</a></span></dt><dt><span class="section"><a href="support.html#std.support.types.numeric_limits">Numeric Properties</a></span></dt><dt><span class="section"><a href="support.html#std.support.types.null">NULL</a></span></dt></dl></dd><dt><span class="section"><a href="dynamic_memory.html">Dynamic Memory</a></span></dt><dt><span class="section"><a href="termination.html">Termination</a></span></dt><dd><dl><dt><span class="section"><a href="termination.html#support.termination.handlers">Termination Handlers</a></span></dt><dt><span class="section"><a href="termination.html#support.termination.verbose">Verbose Terminate Handler</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="diagnostics.html">5. </a></span></dt><dd><dl><dt><span class="section"><a href="support.html#std.support.types">Types</a></span></dt><dd><dl><dt><span class="section"><a href="support.html#std.support.types.fundamental">Fundamental Types</a></span></dt><dt><span class="section"><a href="support.html#std.support.types.numeric_limits">Numeric Properties</a></span></dt><dt><span class="section"><a href="support.html#std.support.types.null">NULL</a></span></dt></dl></dd><dt><span class="section"><a href="dynamic_memory.html">Dynamic Memory</a></span></dt><dd><dl><dt><span class="section"><a href="dynamic_memory.html#std.support.memory.notes">Additional Notes</a></span></dt></dl></dd><dt><span class="section"><a href="termination.html">Termination</a></span></dt><dd><dl><dt><span class="section"><a href="termination.html#support.termination.handlers">Termination Handlers</a></span></dt><dt><span class="section"><a href="termination.html#support.termination.verbose">Verbose Terminate Handler</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="diagnostics.html">5.
Diagnostics Diagnostics
</a></span></dt><dd><dl><dt><span class="section"><a href="diagnostics.html#std.diagnostics.exceptions">Exceptions</a></span></dt><dd><dl><dt><span class="section"><a href="diagnostics.html#std.diagnostics.exceptions.api">API Reference</a></span></dt><dt><span class="section"><a href="diagnostics.html#std.diagnostics.exceptions.data">Adding Data to <code class="classname">exception</code></a></span></dt></dl></dd><dt><span class="section"><a href="errno.html">Use of errno by the library</a></span></dt><dt><span class="section"><a href="concept_checking.html">Concept Checking</a></span></dt></dl></dd><dt><span class="chapter"><a href="utilities.html">6. </a></span></dt><dd><dl><dt><span class="section"><a href="diagnostics.html#std.diagnostics.exceptions">Exceptions</a></span></dt><dd><dl><dt><span class="section"><a href="diagnostics.html#std.diagnostics.exceptions.api">API Reference</a></span></dt><dt><span class="section"><a href="diagnostics.html#std.diagnostics.exceptions.data">Adding Data to <code class="classname">exception</code></a></span></dt></dl></dd><dt><span class="section"><a href="errno.html">Use of errno by the library</a></span></dt><dt><span class="section"><a href="concept_checking.html">Concept Checking</a></span></dt></dl></dd><dt><span class="chapter"><a href="utilities.html">6.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
</th><td width="20%" align="right"> <a accesskey="n" href="dynamic_memory.html">Next</a></td></tr></table><hr /></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="std.support"></a>Chapter 4.  </th><td width="20%" align="right"> <a accesskey="n" href="dynamic_memory.html">Next</a></td></tr></table><hr /></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="std.support"></a>Chapter 4. 
Support Support
<a id="id-1.3.4.2.1.1.1" class="indexterm"></a> <a id="id-1.3.4.2.1.1.1" class="indexterm"></a>
</h2></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="section"><a href="support.html#std.support.types">Types</a></span></dt><dd><dl><dt><span class="section"><a href="support.html#std.support.types.fundamental">Fundamental Types</a></span></dt><dt><span class="section"><a href="support.html#std.support.types.numeric_limits">Numeric Properties</a></span></dt><dt><span class="section"><a href="support.html#std.support.types.null">NULL</a></span></dt></dl></dd><dt><span class="section"><a href="dynamic_memory.html">Dynamic Memory</a></span></dt><dt><span class="section"><a href="termination.html">Termination</a></span></dt><dd><dl><dt><span class="section"><a href="termination.html#support.termination.handlers">Termination Handlers</a></span></dt><dt><span class="section"><a href="termination.html#support.termination.verbose">Verbose Terminate Handler</a></span></dt></dl></dd></dl></div><p> </h2></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="section"><a href="support.html#std.support.types">Types</a></span></dt><dd><dl><dt><span class="section"><a href="support.html#std.support.types.fundamental">Fundamental Types</a></span></dt><dt><span class="section"><a href="support.html#std.support.types.numeric_limits">Numeric Properties</a></span></dt><dt><span class="section"><a href="support.html#std.support.types.null">NULL</a></span></dt></dl></dd><dt><span class="section"><a href="dynamic_memory.html">Dynamic Memory</a></span></dt><dd><dl><dt><span class="section"><a href="dynamic_memory.html#std.support.memory.notes">Additional Notes</a></span></dt></dl></dd><dt><span class="section"><a href="termination.html">Termination</a></span></dt><dd><dl><dt><span class="section"><a href="termination.html#support.termination.handlers">Termination Handlers</a></span></dt><dt><span class="section"><a href="termination.html#support.termination.verbose">Verbose Terminate Handler</a></span></dt></dl></dd></dl></div><p>
This part deals with the functions called and objects created This part deals with the functions called and objects created
automatically during the course of a program's existence. automatically during the course of a program's existence.
</p><p> </p><p>
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
Specializing parts of the library on these types is prohibited: Specializing parts of the library on these types is prohibited:
instead, use a POD. instead, use a POD.
</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="std.support.types.numeric_limits"></a>Numeric Properties</h3></div></div></div><p> </p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="std.support.types.numeric_limits"></a>Numeric Properties</h3></div></div></div><p>
The header <code class="filename">limits</code> defines The header <code class="filename">&lt;limits&gt;</code> defines
traits classes to give access to various implementation traits classes to give access to various implementation
defined-aspects of the fundamental types. The traits classes -- defined-aspects of the fundamental types. The traits classes --
fourteen in total -- are all specializations of the class template fourteen in total -- are all specializations of the class template
...@@ -102,28 +102,36 @@ ...@@ -102,28 +102,36 @@
The only change that might affect people is the type of The only change that might affect people is the type of
<code class="constant">NULL</code>: while it is required to be a macro, <code class="constant">NULL</code>: while it is required to be a macro,
the definition of that macro is <span class="emphasis"><em>not</em></span> allowed the definition of that macro is <span class="emphasis"><em>not</em></span> allowed
to be <code class="constant">(void*)0</code>, which is often used in C. to be an expression with pointer type such as
<code class="constant">(void*)0</code>, which is often used in C.
</p><p> </p><p>
For <span class="command"><strong>g++</strong></span>, <code class="constant">NULL</code> is For <span class="command"><strong>g++</strong></span>, <code class="constant">NULL</code> is
<code class="code">#define</code>'d to be <code class="code">#define</code>'d to be
<code class="constant">__null</code>, a magic keyword extension of <code class="constant">__null</code>, a magic keyword extension of
<span class="command"><strong>g++</strong></span>. <span class="command"><strong>g++</strong></span> that is slightly safer than a plain integer.
</p><p> </p><p>
The biggest problem of #defining <code class="constant">NULL</code> to be The biggest problem of #defining <code class="constant">NULL</code> to be
something like <span class="quote"><span class="quote">0L</span></span> is that the compiler will view something like <span class="quote"><span class="quote">0L</span></span> is that the compiler will view
that as a long integer before it views it as a pointer, so that as a long integer before it views it as a pointer, so
overloading won't do what you expect. (This is why overloading won't do what you expect. It might not even have the
<span class="command"><strong>g++</strong></span> has a magic extension, so that same size as a pointer, so passing <code class="constant">NULL</code> to a
<code class="constant">NULL</code> is always a pointer.) varargs function where a pointer is expected might not even work
</p><p>In his book <a class="link" href="http://www.aristeia.com/books.html" target="_top"><span class="emphasis"><em>Effective correctly if <code class="code">sizeof(NULL) &lt; sizeof(void*)</code>.
C++</em></span></a>, Scott Meyers points out that the best way The G++ <code class="constant">__null</code> extension is defined so that
to solve this problem is to not overload on pointer-vs-integer <code class="code">sizeof(__null) == sizeof(void*)</code> to avoid this problem.
types to begin with. He also offers a way to make your own magic </p><p>
<code class="constant">NULL</code> that will match pointers before it Scott Meyers explains this in more detail in his book
matches integers. <a class="link" href="https://www.aristeia.com/books.html" target="_top"><span class="emphasis"><em>Effective
</p><p>See the Modern C++</em></span></a> and as a guideline to solve this problem
<a class="link" href="http://www.aristeia.com/books.html" target="_top"><span class="emphasis"><em>Effective recommends to not overload on pointer-vs-integer types to begin with.
C++ CD</em></span></a> example. </p><p>
The C++ 2011 standard added the <code class="constant">nullptr</code> keyword,
which is a null pointer constant of a special type,
<code class="classname">std::nullptr_t</code>. Values of this type can be
implicitly converted to <span class="emphasis"><em>any</em></span> pointer type,
and cannot convert to integer types or be deduced as an integer type.
Unless you need to be compatible with C++98/C++03 or C you should prefer
to use <code class="constant">nullptr</code> instead of <code class="constant">NULL</code>.
</p></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="std_contents.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="std_contents.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="dynamic_memory.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Part II.  </p></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="std_contents.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="std_contents.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="dynamic_memory.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Part II. 
Standard Contents Standard Contents
 </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Dynamic Memory</td></tr></table></div></body></html>  </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Dynamic Memory</td></tr></table></div></body></html>
\ No newline at end of file
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
Support Support
</th><td width="20%" align="right"> <a accesskey="n" href="diagnostics.html">Next</a></td></tr></table><hr /></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="std.support.termination"></a>Termination</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="support.termination.handlers"></a>Termination Handlers</h3></div></div></div><p> </th><td width="20%" align="right"> <a accesskey="n" href="diagnostics.html">Next</a></td></tr></table><hr /></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="std.support.termination"></a>Termination</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="support.termination.handlers"></a>Termination Handlers</h3></div></div></div><p>
Not many changes here to <code class="filename">cstdlib</code>. You should note that the Not many changes here to
<code class="filename">&lt;cstdlib&gt;</code>.
You should note that the
<code class="function">abort()</code> function does not call the <code class="function">abort()</code> function does not call the
destructors of automatic nor static objects, so if you're destructors of automatic nor static objects, so if you're
depending on those to do cleanup, it isn't going to happen. depending on those to do cleanup, it isn't going to happen.
...@@ -24,8 +26,8 @@ ...@@ -24,8 +26,8 @@
The previous two actions are <span class="quote"><span class="quote">interleaved,</span></span> that is, The previous two actions are <span class="quote"><span class="quote">interleaved,</span></span> that is,
given this pseudocode: given this pseudocode:
</p><pre class="programlisting"> </p><pre class="programlisting">
extern "C or C++" void f1 (void); extern "C or C++" void f1 ();
extern "C or C++" void f2 (void); extern "C or C++" void f2 ();
static Thing obj1; static Thing obj1;
atexit(f1); atexit(f1);
...@@ -43,11 +45,20 @@ ...@@ -43,11 +45,20 @@
Note also that <code class="function">atexit()</code> is only required to store 32 Note also that <code class="function">atexit()</code> is only required to store 32
functions, and the compiler/library might already be using some of functions, and the compiler/library might already be using some of
those slots. If you think you may run out, we recommend using those slots. If you think you may run out, we recommend using
the <code class="function">xatexit</code>/<code class="function">xexit</code> combination from <code class="literal">libiberty</code>, which has no such limit. the <code class="function">xatexit</code>/<code class="function">xexit</code> combination
from <code class="literal">libiberty</code>, which has no such limit.
</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="support.termination.verbose"></a>Verbose Terminate Handler</h3></div></div></div><p> </p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="support.termination.verbose"></a>Verbose Terminate Handler</h3></div></div></div><p>
If you are having difficulty with uncaught exceptions and want a If you are having difficulty with uncaught exceptions and want a
little bit of help debugging the causes of the core dumps, you can little bit of help debugging the causes of the core dumps, you can
make use of a GNU extension, the verbose terminate handler. make use of a GNU extension, the verbose terminate handler.
</p><p>
The verbose terminate handler is only available for hosted environments
(see <a class="xref" href="configure.html" title="Configure">Configuring</a>) and will be used
by default unless the library is built with
<code class="option">--disable-libstdcxx-verbose</code>
or with exceptions disabled.
If you need to enable it explicitly you can do so by calling the
<code class="function">std::set_terminate</code> function.
</p><pre class="programlisting"> </p><pre class="programlisting">
#include &lt;exception&gt; #include &lt;exception&gt;
...@@ -61,12 +72,13 @@ int main() ...@@ -61,12 +72,13 @@ int main()
</pre><p> </pre><p>
The <code class="function">__verbose_terminate_handler</code> function The <code class="function">__verbose_terminate_handler</code> function
obtains the name of the current exception, attempts to demangle obtains the name of the current exception, attempts to demangle
it, and prints it to stderr. If the exception is derived from it, and prints it to <code class="literal">stderr</code>.
<code class="classname">exception</code> then the output from If the exception is derived from
<code class="classname">std::exception</code> then the output from
<code class="function">what()</code> will be included. <code class="function">what()</code> will be included.
</p><p> </p><p>
Any replacement termination function is required to kill the Any replacement termination function is required to kill the
program without returning; this one calls abort. program without returning; this one calls <code class="function">std::abort</code>.
</p><p> </p><p>
For example: For example:
</p><pre class="programlisting"> </p><pre class="programlisting">
...@@ -99,13 +111,14 @@ int main(int argc) ...@@ -99,13 +111,14 @@ int main(int argc)
Aborted Aborted
</code> </code>
</pre><p> </pre><p>
The 'Aborted' line comes from the call to The 'Aborted' line is printed by the shell after the process exits
<code class="function">abort()</code>, of course. by calling <code class="function">abort()</code>.
</p><p> </p><p>
This is the default termination handler; nothing need be done to As this is the default termination handler, nothing need be done to
use it. To go back to the previous <span class="quote"><span class="quote">silent death</span></span> use it. To go back to the previous <span class="quote"><span class="quote">silent death</span></span>
method, simply include <code class="filename">exception</code> and method, simply include
<code class="filename">cstdlib</code>, and call <code class="filename">&lt;exception&gt;</code> and
<code class="filename">&lt;cstdlib&gt;</code>, and call
</p><pre class="programlisting"> </p><pre class="programlisting">
std::set_terminate(std::abort); std::set_terminate(std::abort);
</pre><p> </pre><p>
...@@ -113,8 +126,8 @@ int main(int argc) ...@@ -113,8 +126,8 @@ int main(int argc)
<code class="function">abort</code> as the terminate handler. <code class="function">abort</code> as the terminate handler.
</p><p> </p><p>
Note: the verbose terminate handler will attempt to write to Note: the verbose terminate handler will attempt to write to
stderr. If your application closes stderr or redirects it to an <code class="literal">stderr</code>. If your application closes
inappropriate location, <code class="literal">stderr</code> or redirects it to an inappropriate location,
<code class="function">__verbose_terminate_handler</code> will behave in <code class="function">__verbose_terminate_handler</code> will behave in
an unspecified manner. an unspecified manner.
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="dynamic_memory.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="support.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="diagnostics.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Dynamic Memory </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 5.  </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="dynamic_memory.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="support.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="diagnostics.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Dynamic Memory </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 5. 
......
...@@ -21,28 +21,38 @@ ...@@ -21,28 +21,38 @@
<section xml:id="std.diagnostics.exceptions.api"><info><title>API Reference</title></info> <section xml:id="std.diagnostics.exceptions.api"><info><title>API Reference</title></info>
<para> <para>
All exception objects are defined in one of the standard header Most exception classes are defined in one of the standard headers
files: <filename>exception</filename>, <filename class="headerfile">&lt;exception&gt;</filename>,
<filename>stdexcept</filename>, <filename>new</filename>, and <filename class="headerfile">&lt;stdexcept&gt;</filename>,
<filename>typeinfo</filename>. <filename class="headerfile">&lt;new&gt;</filename>, and
<filename class="headerfile">&lt;typeinfo&gt;</filename>.
The C++ 2011 revision of the standard added more exception types
in the headers
<filename class="headerfile">&lt;functional&gt;</filename>,
<filename class="headerfile">&lt;future&gt;</filename>,
<filename class="headerfile">&lt;regex&gt;</filename>, and
<filename class="headerfile">&lt;system_error&gt;</filename>.
The C++ 2017 revision of the standard added more exception types
in the headers
<filename class="headerfile">&lt;any&gt;</filename>,
<filename class="headerfile">&lt;filesystem&gt;</filename>,
<filename class="headerfile">&lt;optional&gt;</filename>, and
<filename class="headerfile">&lt;variant&gt;</filename>.
</para> </para>
<para> <para>
The base exception object is <classname>exception</classname>, All exceptions thrown by the library have a base class of type
located in <filename>exception</filename>. This object has no <classname>std::exception</classname>,
<classname>string</classname> member. defined in <filename class="headerfile">&lt;exception&gt;</filename>.
This type has no <classname>std::string</classname> member.
</para> </para>
<para> <para>
Derived from this are several classes that may have a Derived from this are several classes that may have a
<classname>string</classname> member: a full hierarchy can be <classname>std::string</classname> member. A full hierarchy can be
found in the source documentation. found in the source documentation.
</para> </para>
<para>
Full API details.
</para>
<!-- Doxygen XML: api/group__exceptions.xml --> <!-- Doxygen XML: api/group__exceptions.xml -->
</section> </section>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment