summaryrefslogtreecommitdiff
path: root/libstdc++-v3/doc/xml
diff options
context:
space:
mode:
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2015-10-01 11:23:39 +0000
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2015-10-01 11:23:39 +0000
commit12ae83b7bb49d843751c78788c9099c8071c8b1a (patch)
treea019470ff02af16e5d85abeda9ad9e5dc945f92f /libstdc++-v3/doc/xml
parent7e93eb1a344eea57038b0bf24556aed75034f204 (diff)
downloadgcc-12ae83b7bb49d843751c78788c9099c8071c8b1a.tar.gz
Save-and-restore errno more carefully in libstdc++
* doc/xml/manual/diagnostics.xml: Document use of errno. * doc/html/*: Regenerate. * config/locale/generic/c_locale.cc (_Save_errno): New helper. (__convert_to_v): Use _Save_errno. * include/ext/string_conversions.h (__stoa): Only restore errno when it isn't set to non-zero. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228328 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/doc/xml')
-rw-r--r--libstdc++-v3/doc/xml/manual/diagnostics.xml33
1 files changed, 33 insertions, 0 deletions
diff --git a/libstdc++-v3/doc/xml/manual/diagnostics.xml b/libstdc++-v3/doc/xml/manual/diagnostics.xml
index 88ed2e28057..67620e2cb40 100644
--- a/libstdc++-v3/doc/xml/manual/diagnostics.xml
+++ b/libstdc++-v3/doc/xml/manual/diagnostics.xml
@@ -71,6 +71,39 @@
</section>
</section>
+<section xml:id="std.diagnostics.errno" xreflabel="errno"><info><title>Use of errno by the library</title></info>
+ <?dbhtml filename="errno.html"?>
+
+ <para>
+ The C and POSIX standards guarantee that <varname>errno</varname>
+ is never set to zero by any library function.
+ The C++ standard has less to say about when <varname>errno</varname>
+ is or isn't set, but libstdc++ follows the same rule and never sets
+ it to zero.
+ </para>
+
+ <para>
+ On the other hand, there are few guarantees about when the C++ library
+ sets <varname>errno</varname> on error, beyond what is specified for
+ functions that come from the C library.
+ For example, when <function>std::stoi</function> throws an exception of
+ type <classname>std::out_of_range</classname>, <varname>errno</varname>
+ may or may not have been set to <constant>ERANGE</constant>.
+ </para>
+
+ <para>
+ Parts of the C++ library may be implemented in terms of C library
+ functions, which may result in <varname>errno</varname> being set
+ with no explicit call to a C function. For example, on a target where
+ <function>operator new</function> uses <function>malloc</function>
+ a failed memory allocation with <function>operator new</function> might
+ set <varname>errno</varname> to <constant>ENOMEM</constant>.
+ Which C++ library functions can set <varname>errno</varname> in this way
+ is unspecified because it may vary between platforms and between releases.
+ </para>
+
+</section>
+
<section xml:id="std.diagnostics.concept_checking" xreflabel="Concept Checking"><info><title>Concept Checking</title></info>
<?dbhtml filename="concept_checking.html"?>