1<?xml version="1.0" encoding="UTF-8" standalone="no"?> 2<!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>Use of errno by the library</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><meta name="keywords" content="ISO C++, library" /><meta name="keywords" content="ISO C++, runtime, library" /><link rel="home" href="../index.html" title="The GNU C++ Library" /><link rel="up" href="diagnostics.html" title="Chapter��5.�� Diagnostics" /><link rel="prev" href="diagnostics.html" title="Chapter��5.�� Diagnostics" /><link rel="next" href="concept_checking.html" title="Concept Checking" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Use of errno by the library</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="diagnostics.html">Prev</a>��</td><th width="60%" align="center">Chapter��5.�� 3 Diagnostics 4 5</th><td width="20%" align="right">��<a accesskey="n" href="concept_checking.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.diagnostics.errno"></a>Use of errno by the library</h2></div></div></div><p> 6 The C and POSIX standards guarantee that <code class="varname">errno</code> 7 is never set to zero by any library function. 8 The C++ standard has less to say about when <code class="varname">errno</code> 9 is or isn't set, but libstdc++ follows the same rule and never sets 10 it to zero. 11 </p><p> 12 On the other hand, there are few guarantees about when the C++ library 13 sets <code class="varname">errno</code> on error, beyond what is specified for 14 functions that come from the C library. 15 For example, when <code class="function">std::stoi</code> throws an exception of 16 type <code class="classname">std::out_of_range</code>, <code class="varname">errno</code> 17 may or may not have been set to <code class="constant">ERANGE</code>. 18 </p><p> 19 Parts of the C++ library may be implemented in terms of C library 20 functions, which may result in <code class="varname">errno</code> being set 21 with no explicit call to a C function. For example, on a target where 22 <code class="function">operator new</code> uses <code class="function">malloc</code> 23 a failed memory allocation with <code class="function">operator new</code> might 24 set <code class="varname">errno</code> to <code class="constant">ENOMEM</code>. 25 Which C++ library functions can set <code class="varname">errno</code> in this way 26 is unspecified because it may vary between platforms and between releases. 27 </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="diagnostics.html">Prev</a>��</td><td width="20%" align="center"><a accesskey="u" href="diagnostics.html">Up</a></td><td width="40%" align="right">��<a accesskey="n" href="concept_checking.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter��5.�� 28 Diagnostics 29 30��</td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top">��Concept Checking</td></tr></table></div></body></html>