xref: /netbsd-src/external/gpl3/gcc.old/dist/libstdc++-v3/doc/html/faq.html (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
136ac495dSmrg<?xml version="1.0" encoding="UTF-8" standalone="no"?>
236ac495dSmrg<!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>Frequently Asked Questions</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><meta name="keywords" content="ISO C++, runtime, library" /><link rel="home" href="index.html" title="The GNU C++ Library" /><link rel="up" href="bk03.html" title="" /><link rel="prev" href="bk03.html" title="" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Frequently Asked Questions</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="bk03.html">Prev</a> </td><th width="60%" align="center"></th><td width="20%" align="right"> </td></tr></table><hr /></div><div class="article"><div class="titlepage"><div><div><h1 class="title"><a id="faq"></a>Frequently Asked Questions</h1></div><div><p class="copyright">Copyright ©
3a2dc1f3fSmrg      2008-2018
436ac495dSmrg
5a2dc1f3fSmrg      <a class="link" href="https://www.fsf.org" target="_top">FSF</a>
636ac495dSmrg    </p></div></div><hr /></div><div class="qandaset"><a id="faq.faq"></a><dl><dt></dt><dd><dl><dt>1.1. <a href="faq.html#faq.what">
736ac495dSmrg      What is libstdc++?
836ac495dSmrg    </a></dt><dt>1.2. <a href="faq.html#faq.why">
936ac495dSmrg      Why should I use libstdc++?
1036ac495dSmrg    </a></dt><dt>1.3. <a href="faq.html#faq.who">
1136ac495dSmrg      Who's in charge of it?
1236ac495dSmrg    </a></dt><dt>1.4. <a href="faq.html#faq.when">
1336ac495dSmrg      When is libstdc++ going to be finished?
1436ac495dSmrg    </a></dt><dt>1.5. <a href="faq.html#faq.how">
1536ac495dSmrg      How do I contribute to the effort?
1636ac495dSmrg    </a></dt><dt>1.6. <a href="faq.html#faq.whereis_old">
1736ac495dSmrg      What happened to the older libg++? I need that!
1836ac495dSmrg    </a></dt><dt>1.7. <a href="faq.html#faq.more_questions">
1936ac495dSmrg      What if I have more questions?
2036ac495dSmrg    </a></dt></dl></dd><dt></dt><dd><dl><dt>2.1. <a href="faq.html#faq.license.what">
2136ac495dSmrg      What are the license terms for libstdc++?
2236ac495dSmrg    </a></dt><dt>2.2. <a href="faq.html#faq.license.any_program">
2336ac495dSmrg      So any program which uses libstdc++ falls under the GPL?
2436ac495dSmrg    </a></dt><dt>2.3. <a href="faq.html#faq.license.lgpl">
2536ac495dSmrg      How is that different from the GNU {Lesser,Library} GPL?
2636ac495dSmrg    </a></dt><dt>2.4. <a href="faq.html#faq.license.what_restrictions">
2736ac495dSmrg      I see. So, what restrictions are there on programs that use the library?
2836ac495dSmrg    </a></dt></dl></dd><dt></dt><dd><dl><dt>3.1. <a href="faq.html#faq.how_to_install">How do I install libstdc++?
2936ac495dSmrg    </a></dt><dt>3.2. <a href="faq.html#faq.how_to_get_sources">How does one get current libstdc++ sources?
3036ac495dSmrg    </a></dt><dt>3.3. <a href="faq.html#faq.how_to_test">How do I know if it works?
3136ac495dSmrg    </a></dt><dt>3.4. <a href="faq.html#faq.how_to_set_paths">How do I insure that the dynamically linked library will be found?
3236ac495dSmrg    </a></dt><dt>3.5. <a href="faq.html#faq.what_is_libsupcxx">
3336ac495dSmrg      What's libsupc++?
3436ac495dSmrg    </a></dt><dt>3.6. <a href="faq.html#faq.size">
3536ac495dSmrg      This library is HUGE!
3636ac495dSmrg    </a></dt></dl></dd><dt></dt><dd><dl><dt>4.1. <a href="faq.html#faq.other_compilers">
3736ac495dSmrg      Can libstdc++ be used with non-GNU compilers?
3836ac495dSmrg    </a></dt><dt>4.2. <a href="faq.html#faq.solaris_long_long">
3936ac495dSmrg      No 'long long' type on Solaris?
4036ac495dSmrg    </a></dt><dt>4.3. <a href="faq.html#faq.predefined">
4136ac495dSmrg      _XOPEN_SOURCE and _GNU_SOURCE are always defined?
4236ac495dSmrg    </a></dt><dt>4.4. <a href="faq.html#faq.darwin_ctype">
4336ac495dSmrg      Mac OS X ctype.h is broken! How can I fix it?
4436ac495dSmrg    </a></dt><dt>4.5. <a href="faq.html#faq.threads_i386">
4536ac495dSmrg      Threading is broken on i386?
4636ac495dSmrg    </a></dt><dt>4.6. <a href="faq.html#faq.atomic_mips">
4736ac495dSmrg      MIPS atomic operations
4836ac495dSmrg    </a></dt><dt>4.7. <a href="faq.html#faq.linux_glibc">
4936ac495dSmrg      Recent GNU/Linux glibc required?
5036ac495dSmrg    </a></dt><dt>4.8. <a href="faq.html#faq.freebsd_wchar">
5136ac495dSmrg      Can't use wchar_t/wstring on FreeBSD
5236ac495dSmrg    </a></dt></dl></dd><dt></dt><dd><dl><dt>5.1. <a href="faq.html#faq.what_works">
5336ac495dSmrg      What works already?
5436ac495dSmrg    </a></dt><dt>5.2. <a href="faq.html#faq.standard_bugs">
5536ac495dSmrg      Bugs in the ISO C++ language or library specification
5636ac495dSmrg    </a></dt><dt>5.3. <a href="faq.html#faq.compiler_bugs">
5736ac495dSmrg      Bugs in the compiler (gcc/g++) and not libstdc++
5836ac495dSmrg    </a></dt></dl></dd><dt></dt><dd><dl><dt>6.1. <a href="faq.html#faq.stream_reopening_fails">
5936ac495dSmrg      Reopening a stream fails
6036ac495dSmrg    </a></dt><dt>6.2. <a href="faq.html#faq.wefcxx_verbose">
6136ac495dSmrg      -Weffc++ complains too much
6236ac495dSmrg    </a></dt><dt>6.3. <a href="faq.html#faq.ambiguous_overloads">
6336ac495dSmrg      Ambiguous overloads after including an old-style header
6436ac495dSmrg    </a></dt><dt>6.4. <a href="faq.html#faq.v2_headers">
6536ac495dSmrg      The g++-3 headers are not ours
6636ac495dSmrg    </a></dt><dt>6.5. <a href="faq.html#faq.boost_concept_checks">
6736ac495dSmrg      Errors about *Concept and
6836ac495dSmrg      constraints in the STL
6936ac495dSmrg    </a></dt><dt>6.6. <a href="faq.html#faq.dlopen_crash">
7036ac495dSmrg      Program crashes when using library code in a
7136ac495dSmrg      dynamically-loaded library
7236ac495dSmrg    </a></dt><dt>6.7. <a href="faq.html#faq.memory_leaks">
73a2dc1f3fSmrg      “Memory leaks” in libstdc++
7436ac495dSmrg    </a></dt><dt>6.8. <a href="faq.html#faq.list_size_on">
7536ac495dSmrg      list::size() is O(n)!
7636ac495dSmrg    </a></dt><dt>6.9. <a href="faq.html#faq.easy_to_fix">
7736ac495dSmrg      Aw, that's easy to fix!
7836ac495dSmrg    </a></dt></dl></dd><dt></dt><dd><dl><dt>7.1. <a href="faq.html#faq.iterator_as_pod">
79a2dc1f3fSmrg      string::iterator is not char*;
80a2dc1f3fSmrg      vector&lt;T&gt;::iterator is not T*
8136ac495dSmrg    </a></dt><dt>7.2. <a href="faq.html#faq.what_is_next">
8236ac495dSmrg      What's next after libstdc++?
8336ac495dSmrg    </a></dt><dt>7.3. <a href="faq.html#faq.sgi_stl">
8436ac495dSmrg      What about the STL from SGI?
8536ac495dSmrg    </a></dt><dt>7.4. <a href="faq.html#faq.extensions_and_backwards_compat">
8636ac495dSmrg      Extensions and Backward Compatibility
8736ac495dSmrg    </a></dt><dt>7.5. <a href="faq.html#faq.tr1_support">
8836ac495dSmrg      Does libstdc++ support TR1?
8936ac495dSmrg    </a></dt><dt>7.6. <a href="faq.html#faq.get_iso_cxx">How do I get a copy of the ISO C++ Standard?
9036ac495dSmrg    </a></dt><dt>7.7. <a href="faq.html#faq.what_is_abi">
9136ac495dSmrg      What's an ABI and why is it so messy?
9236ac495dSmrg    </a></dt><dt>7.8. <a href="faq.html#faq.size_equals_capacity">
9336ac495dSmrg      How do I make std::vector&lt;T&gt;::capacity() == std::vector&lt;T&gt;::size?
9436ac495dSmrg    </a></dt></dl></dd></dl><table border="0" style="width: 100%;"><colgroup><col align="left" width="1%" /><col /></colgroup><tbody><tr class="toc"><td align="left" valign="top" colspan="2"><dl><dt>1.1. <a href="faq.html#faq.what">
9536ac495dSmrg      What is libstdc++?
9636ac495dSmrg    </a></dt><dt>1.2. <a href="faq.html#faq.why">
9736ac495dSmrg      Why should I use libstdc++?
9836ac495dSmrg    </a></dt><dt>1.3. <a href="faq.html#faq.who">
9936ac495dSmrg      Who's in charge of it?
10036ac495dSmrg    </a></dt><dt>1.4. <a href="faq.html#faq.when">
10136ac495dSmrg      When is libstdc++ going to be finished?
10236ac495dSmrg    </a></dt><dt>1.5. <a href="faq.html#faq.how">
10336ac495dSmrg      How do I contribute to the effort?
10436ac495dSmrg    </a></dt><dt>1.6. <a href="faq.html#faq.whereis_old">
10536ac495dSmrg      What happened to the older libg++? I need that!
10636ac495dSmrg    </a></dt><dt>1.7. <a href="faq.html#faq.more_questions">
10736ac495dSmrg      What if I have more questions?
10836ac495dSmrg    </a></dt></dl></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.what"></a><a id="faq.what.q"></a><p><strong>1.1.</strong></p></td><td align="left" valign="top"><p>
10936ac495dSmrg      What is libstdc++?
11036ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="faq.what.a"></a></td><td align="left" valign="top"><p>
11136ac495dSmrg     The GNU Standard C++ Library v3 is an ongoing project to
112a2dc1f3fSmrg     implement the ISO 14882 C++ Standard Library as described in
113a2dc1f3fSmrg     clauses 20 through 33 and annex D (prior to the 2017 standard
114a2dc1f3fSmrg     the library clauses started with 17).  For those who want to see
11536ac495dSmrg     exactly how far the project has come, or just want the latest
116a2dc1f3fSmrg     bleeding-edge code, the up-to-date source can be cloned via
117a2dc1f3fSmrg     <a class="link" href="https://gcc.gnu.org/git.html" target="_top">Git</a>.
118a2dc1f3fSmrg    </p><p>
119a2dc1f3fSmrg    N.B. The library is called libstdc++ <span class="emphasis"><em>not</em></span> stdlibc++.
12036ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.why"></a><a id="q-why"></a><p><strong>1.2.</strong></p></td><td align="left" valign="top"><p>
12136ac495dSmrg      Why should I use libstdc++?
12236ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-why"></a></td><td align="left" valign="top"><p>
12336ac495dSmrg    The completion of the initial ISO C++ standardization effort gave the C++
12436ac495dSmrg    community a powerful set of reuseable tools in the form of the C++
12536ac495dSmrg    Standard Library.  However, for several years C++ implementations were
12636ac495dSmrg    (as the Draft Standard used to say) <span class="quote">“<span class="quote">incomplet and
12736ac495dSmrg    incorrekt</span>”</span>, and many suffered from limitations of the compilers
12836ac495dSmrg    that used them.
12936ac495dSmrg    </p><p>
13036ac495dSmrg    The GNU compiler collection
13136ac495dSmrg    (<span class="command"><strong>gcc</strong></span>, <span class="command"><strong>g++</strong></span>, etc) is widely
13236ac495dSmrg    considered to be one of the leading compilers in the world.  Its
13336ac495dSmrg    development is overseen by the
13436ac495dSmrg    <a class="link" href="https://gcc.gnu.org/" target="_top">GCC team</a>.  All of
13536ac495dSmrg    the rapid development and near-legendary
13636ac495dSmrg    <a class="link" href="https://gcc.gnu.org/buildstat.html" target="_top">portability</a>
13736ac495dSmrg    that are the hallmarks of an open-source project are applied to libstdc++.
13836ac495dSmrg    </p><p>
139a2dc1f3fSmrg    All of the standard classes and functions from C++98/C++03, C++11 and C++14
14036ac495dSmrg    (such as <code class="classname">string</code>,
14136ac495dSmrg    <code class="classname">vector&lt;&gt;</code>, iostreams, algorithms etc.)
142a2dc1f3fSmrg    are freely available and attempt to be fully compliant.
14336ac495dSmrg    Work is ongoing to complete support for the current revision of the
14436ac495dSmrg    ISO C++ Standard.
14536ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.who"></a><a id="q-who"></a><p><strong>1.3.</strong></p></td><td align="left" valign="top"><p>
14636ac495dSmrg      Who's in charge of it?
14736ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-who"></a></td><td align="left" valign="top"><p>
14836ac495dSmrg     The libstdc++ project is contributed to by several developers
14936ac495dSmrg     all over the world, in the same way as GCC or the Linux kernel.
15036ac495dSmrg     The current maintainers are listed in the
15136ac495dSmrg     <a class="link" href="https://gcc.gnu.org/viewcvs/gcc/trunk/MAINTAINERS?view=co" target="_top"><code class="filename">MAINTAINERS</code></a>
15236ac495dSmrg     file (look for "c++ runtime libs").
15336ac495dSmrg    </p><p>
15436ac495dSmrg    Development and discussion is held on the libstdc++ mailing
15536ac495dSmrg    list.  Subscribing to the list, or searching the list
15636ac495dSmrg    archives, is open to everyone.  You can read instructions for
15736ac495dSmrg    doing so on the <a class="link" href="https://gcc.gnu.org/lists.html" target="_top">GCC mailing lists</a> page.
15836ac495dSmrg    If you have questions, ideas, code, or are just curious, sign up!
15936ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.when"></a><a id="q-when"></a><p><strong>1.4.</strong></p></td><td align="left" valign="top"><p>
16036ac495dSmrg      When is libstdc++ going to be finished?
16136ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-when"></a></td><td align="left" valign="top"><p>
16236ac495dSmrg    Nathan Myers gave the best of all possible answers, responding to
16336ac495dSmrg    a Usenet article asking this question: <span class="emphasis"><em>Sooner, if you
16436ac495dSmrg    help.</em></span>
16536ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.how"></a><a id="q-how"></a><p><strong>1.5.</strong></p></td><td align="left" valign="top"><p>
16636ac495dSmrg      How do I contribute to the effort?
16736ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-how"></a></td><td align="left" valign="top"><p>
16836ac495dSmrg    See the <a class="link" href="manual/appendix_contributing.html" title="Appendix A.  Contributing">Contributing</a> section in
16936ac495dSmrg    the manual. Subscribing to the mailing list (see above, or
17036ac495dSmrg    the homepage) is a very good idea if you have something to
17136ac495dSmrg    contribute, or if you have spare time and want to
17236ac495dSmrg    help. Contributions don't have to be in the form of source code;
17336ac495dSmrg    anybody who is willing to help write documentation, for example,
17436ac495dSmrg    or has found a bug in code that we all thought was working and is
17536ac495dSmrg    willing to provide details, is more than welcome!
17636ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.whereis_old"></a><a id="q-whereis_old"></a><p><strong>1.6.</strong></p></td><td align="left" valign="top"><p>
17736ac495dSmrg      What happened to the older libg++? I need that!
17836ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-whereis_old"></a></td><td align="left" valign="top"><p>
17936ac495dSmrg    The last libg++ README states
18036ac495dSmrg    <span class="quote">“<span class="quote">This package is considered obsolete and is no longer
18136ac495dSmrg    being developed.</span>”</span>
18236ac495dSmrg    It should not be used for new projects, and won't even compile with
18336ac495dSmrg    recent releases of GCC (or most other C++ compilers).
18436ac495dSmrg    </p><p>
18536ac495dSmrg    More information can be found in the
18636ac495dSmrg    <a class="link" href="manual/backwards.html" title="Backwards Compatibility">Backwards
18736ac495dSmrg    Compatibility</a> section of the libstdc++ manual.
18836ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.more_questions"></a><a id="q-more_questions"></a><p><strong>1.7.</strong></p></td><td align="left" valign="top"><p>
18936ac495dSmrg      What if I have more questions?
19036ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-more_questions"></a></td><td align="left" valign="top"><p>
19136ac495dSmrg    If you have read the documentation, and your question remains
19236ac495dSmrg    unanswered, then just ask the mailing list. At present, you do not
19336ac495dSmrg    need to be subscribed to the list to send a message to it.  More
19436ac495dSmrg    information is available on the homepage (including how to browse
19536ac495dSmrg    the list archives); to send a message to the list,
19636ac495dSmrg    use <code class="email">&lt;<a class="email" href="mailto:libstdc++@gcc.gnu.org">libstdc++@gcc.gnu.org</a>&gt;</code>.
19736ac495dSmrg    </p><p>
19836ac495dSmrg    If you have a question that you think should be included
19936ac495dSmrg    here, or if you have a question <span class="emphasis"><em>about</em></span> a question/answer
20036ac495dSmrg    here, please send email to the libstdc++ mailing list, as above.
20136ac495dSmrg    </p></td></tr><tr class="toc"><td align="left" valign="top" colspan="2"><dl><dt>2.1. <a href="faq.html#faq.license.what">
20236ac495dSmrg      What are the license terms for libstdc++?
20336ac495dSmrg    </a></dt><dt>2.2. <a href="faq.html#faq.license.any_program">
20436ac495dSmrg      So any program which uses libstdc++ falls under the GPL?
20536ac495dSmrg    </a></dt><dt>2.3. <a href="faq.html#faq.license.lgpl">
20636ac495dSmrg      How is that different from the GNU {Lesser,Library} GPL?
20736ac495dSmrg    </a></dt><dt>2.4. <a href="faq.html#faq.license.what_restrictions">
20836ac495dSmrg      I see. So, what restrictions are there on programs that use the library?
20936ac495dSmrg    </a></dt></dl></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.license.what"></a><a id="q-license.what"></a><p><strong>2.1.</strong></p></td><td align="left" valign="top"><p>
21036ac495dSmrg      What are the license terms for libstdc++?
21136ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-license.what"></a></td><td align="left" valign="top"><p>
21236ac495dSmrg    See <a class="link" href="manual/license.html" title="License">our license description</a>
21336ac495dSmrg    for these and related questions.
21436ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.license.any_program"></a><a id="q-license.any_program"></a><p><strong>2.2.</strong></p></td><td align="left" valign="top"><p>
21536ac495dSmrg      So any program which uses libstdc++ falls under the GPL?
21636ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-license.any_program"></a></td><td align="left" valign="top"><p>
21736ac495dSmrg     No. The special exception permits use of the library in
21836ac495dSmrg     proprietary applications.
21936ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.license.lgpl"></a><a id="q-license.lgpl"></a><p><strong>2.3.</strong></p></td><td align="left" valign="top"><p>
22036ac495dSmrg      How is that different from the GNU {Lesser,Library} GPL?
22136ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-license.lgpl"></a></td><td align="left" valign="top"><p>
22236ac495dSmrg      The LGPL requires that users be able to replace the LGPL code with a
22336ac495dSmrg     modified version; this is trivial if the library in question is a C
22436ac495dSmrg     shared library.  But there's no way to make that work with C++, where
22536ac495dSmrg     much of the library consists of inline functions and templates, which
22636ac495dSmrg     are expanded inside the code that uses the library.  So to allow people
22736ac495dSmrg     to replace the library code, someone using the library would have to
22836ac495dSmrg     distribute their own source, rendering the LGPL equivalent to the GPL.
22936ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.license.what_restrictions"></a><a id="q-license.what_restrictions"></a><p><strong>2.4.</strong></p></td><td align="left" valign="top"><p>
23036ac495dSmrg      I see. So, what restrictions are there on programs that use the library?
23136ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-license.what_restrictions"></a></td><td align="left" valign="top"><p>
23236ac495dSmrg      None.  We encourage such programs to be released as free software,
23336ac495dSmrg     but we won't punish you or sue you if you choose otherwise.
23436ac495dSmrg    </p></td></tr><tr class="toc"><td align="left" valign="top" colspan="2"><dl><dt>3.1. <a href="faq.html#faq.how_to_install">How do I install libstdc++?
23536ac495dSmrg    </a></dt><dt>3.2. <a href="faq.html#faq.how_to_get_sources">How does one get current libstdc++ sources?
23636ac495dSmrg    </a></dt><dt>3.3. <a href="faq.html#faq.how_to_test">How do I know if it works?
23736ac495dSmrg    </a></dt><dt>3.4. <a href="faq.html#faq.how_to_set_paths">How do I insure that the dynamically linked library will be found?
23836ac495dSmrg    </a></dt><dt>3.5. <a href="faq.html#faq.what_is_libsupcxx">
23936ac495dSmrg      What's libsupc++?
24036ac495dSmrg    </a></dt><dt>3.6. <a href="faq.html#faq.size">
24136ac495dSmrg      This library is HUGE!
24236ac495dSmrg    </a></dt></dl></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.how_to_install"></a><a id="q-how_to_install"></a><p><strong>3.1.</strong></p></td><td align="left" valign="top"><p>How do I install libstdc++?
24336ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-how_to_install"></a></td><td align="left" valign="top"><p>
24436ac495dSmrg    Often libstdc++ comes pre-installed as an integral part of many
24536ac495dSmrg    existing GNU/Linux and Unix systems, as well as many embedded
24636ac495dSmrg    development tools. It may be necessary to install extra
24736ac495dSmrg    development packages to get the headers, or the documentation, or
24836ac495dSmrg    the source: please consult your vendor for details.
24936ac495dSmrg    </p><p>
25036ac495dSmrg    To build and install from the GNU GCC sources, please consult the
25136ac495dSmrg    <a class="link" href="manual/setup.html" title="Chapter 2. Setup">setup
25236ac495dSmrg    documentation</a> for detailed
25336ac495dSmrg    instructions. You may wish to browse those files ahead
25436ac495dSmrg    of time to get a feel for what's required.
25536ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.how_to_get_sources"></a><a id="q-how_to_get_sources"></a><p><strong>3.2.</strong></p></td><td align="left" valign="top"><p>How does one get current libstdc++ sources?
25636ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-how_to_get_sources"></a></td><td align="left" valign="top"><p>
25736ac495dSmrg    Libstdc++ sources for all official releases can be obtained as
25836ac495dSmrg    part of the GCC sources, available from various sites and
25936ac495dSmrg    mirrors. A full <a class="link" href="https://gcc.gnu.org/mirrors.html" target="_top">list of
26036ac495dSmrg    download sites</a> is provided on the main GCC site.
26136ac495dSmrg    </p><p>
262a2dc1f3fSmrg    Current libstdc++ sources can always be found in the main GCC source
263a2dc1f3fSmrg    repository, available using the appropriate version control tool.
264a2dc1f3fSmrg    At this time, that tool is <span class="application">Git</span>.
265a2dc1f3fSmrg    For more details see the documentation on
266a2dc1f3fSmrg    <a class="link" href="https://gcc.gnu.org/git.html" target="_top">using the Git repository</a>.
26736ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.how_to_test"></a><a id="q-how_to_test"></a><p><strong>3.3.</strong></p></td><td align="left" valign="top"><p>How do I know if it works?
26836ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-how_to_test"></a></td><td align="left" valign="top"><p>
26936ac495dSmrg    Libstdc++ comes with its own validation testsuite, which includes
27036ac495dSmrg    conformance testing, regression testing, ABI testing, and
27136ac495dSmrg    performance testing. Please consult the
27236ac495dSmrg    <a class="link" href="http://gcc.gnu.org/install/test.html" target="_top">testing
27336ac495dSmrg    documentation</a> for GCC and
27436ac495dSmrg    <a class="link" href="manual/test.html" title="Testing">Testing</a> in the libstdc++
27536ac495dSmrg    manual for more details.
27636ac495dSmrg    </p><p>
27736ac495dSmrg    If you find bugs in the testsuite programs themselves, or if you
27836ac495dSmrg    think of a new test program that should be added to the suite,
27936ac495dSmrg    <span class="emphasis"><em>please</em></span> write up your idea and send it to the list!
28036ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.how_to_set_paths"></a><a id="q-how_to_set_paths"></a><p><strong>3.4.</strong></p></td><td align="left" valign="top"><p>How do I insure that the dynamically linked library will be found?
28136ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-how_to_set_paths"></a></td><td align="left" valign="top"><p>
28236ac495dSmrg    Depending on your platform and library version, the error message might
28336ac495dSmrg    be similar to one of the following:
28436ac495dSmrg    </p><pre class="screen">
28536ac495dSmrg    ./a.out: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
28636ac495dSmrg
28736ac495dSmrg    /usr/libexec/ld-elf.so.1: Shared object "libstdc++.so.6" not found
28836ac495dSmrg    </pre><p>
28936ac495dSmrg    This doesn't mean that the shared library isn't installed, only
29036ac495dSmrg    that the dynamic linker can't find it. When a dynamically-linked
29136ac495dSmrg    executable is run the linker finds and loads the required shared
29236ac495dSmrg    libraries by searching a pre-configured list of directories. If
29336ac495dSmrg    the directory where you've installed libstdc++ is not in this list
29436ac495dSmrg    then the libraries won't be found.
29536ac495dSmrg    </p><p>
29636ac495dSmrg    If you already have an older version of libstdc++ installed then the
29736ac495dSmrg    error might look like one of the following instead:
29836ac495dSmrg    </p><pre class="screen">
29936ac495dSmrg    ./a.out: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.20' not found
30036ac495dSmrg    ./a.out: /usr/lib/libstdc++.so.6: version `CXXABI_1.3.8' not found
30136ac495dSmrg    </pre><p>
30236ac495dSmrg    This means the linker found <code class="filename">/usr/lib/libstdc++.so.6</code>
30336ac495dSmrg    but that library belongs to an older version of GCC than was used to
30436ac495dSmrg    compile and link the program <code class="filename">a.out</code> (or some part
30536ac495dSmrg    of it). The program depends on code defined in the newer libstdc++
30636ac495dSmrg    that belongs to the newer version of GCC, so the linker must be told
30736ac495dSmrg    how to find the newer libstdc++ shared library.
30836ac495dSmrg    </p><p>
30936ac495dSmrg    The simplest way to fix this is
31036ac495dSmrg    to use the <code class="envar">LD_LIBRARY_PATH</code> environment variable,
31136ac495dSmrg    which is a colon-separated list of directories in which the linker
31236ac495dSmrg    will search for shared libraries:
31336ac495dSmrg    </p><pre class="screen"><span class="command"><strong>
31436ac495dSmrg    export LD_LIBRARY_PATH=${prefix}/lib:$LD_LIBRARY_PATH
31536ac495dSmrg    </strong></span></pre><p>
31636ac495dSmrg    Here the shell variable <code class="varname">${prefix}</code> is assumed to contain
31736ac495dSmrg    the directory prefix where GCC was installed to. The directory containing
31836ac495dSmrg    the library might depend on whether you want the 32-bit or 64-bit copy
31936ac495dSmrg    of the library, so for example would be
32036ac495dSmrg    <code class="filename">${prefix}/lib64</code> on some systems.
32136ac495dSmrg    The exact environment variable to use will depend on your
32236ac495dSmrg    platform, e.g. <code class="envar">DYLD_LIBRARY_PATH</code> for Darwin,
32336ac495dSmrg    <code class="envar">LD_LIBRARY_PATH_32</code>/<code class="envar">LD_LIBRARY_PATH_64</code>
32436ac495dSmrg    for Solaris 32-/64-bit,
32536ac495dSmrg    and <code class="envar">SHLIB_PATH</code> for HP-UX.
32636ac495dSmrg    </p><p>
32736ac495dSmrg    See the man pages for <span class="command"><strong>ld</strong></span>, <span class="command"><strong>ldd</strong></span>
32836ac495dSmrg    and <span class="command"><strong>ldconfig</strong></span> for more information. The dynamic
32936ac495dSmrg    linker has different names on different platforms but the man page
33036ac495dSmrg    is usually called something such as <code class="filename">ld.so</code>,
33136ac495dSmrg    <code class="filename">rtld</code> or <code class="filename">dld.so</code>.
33236ac495dSmrg    </p><p>
33336ac495dSmrg    Using <code class="envar">LD_LIBRARY_PATH</code> is not always the best solution,
33436ac495dSmrg    <a class="link" href="manual/using_dynamic_or_shared.html#manual.intro.using.linkage.dynamic" title="Finding Dynamic or Shared Libraries">Finding Dynamic or Shared
33536ac495dSmrg    Libraries</a> in the manual gives some alternatives.
33636ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.what_is_libsupcxx"></a><a id="q-what_is_libsupcxx"></a><p><strong>3.5.</strong></p></td><td align="left" valign="top"><p>
33736ac495dSmrg      What's libsupc++?
33836ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-what_is_libsupcxx"></a></td><td align="left" valign="top"><p>
33936ac495dSmrg      If the only functions from <code class="filename">libstdc++.a</code>
34036ac495dSmrg      which you need are language support functions (those listed in
34136ac495dSmrg      <a class="link" href="manual/support.html" title="Chapter 4.  Support">clause 18</a> of the
34236ac495dSmrg      standard, e.g., <code class="function">new</code> and
34336ac495dSmrg      <code class="function">delete</code>), then try linking against
34436ac495dSmrg      <code class="filename">libsupc++.a</code>, which is a subset of
34536ac495dSmrg      <code class="filename">libstdc++.a</code>.  (Using <span class="command"><strong>gcc</strong></span>
34636ac495dSmrg      instead of <span class="command"><strong>g++</strong></span> and explicitly linking in
34736ac495dSmrg      <code class="filename">libsupc++.a</code> via <code class="option">-lsupc++</code>
34836ac495dSmrg      for the final link step will do it).  This library contains only
34936ac495dSmrg      those support routines, one per object file.  But if you are
35036ac495dSmrg      using anything from the rest of the library, such as IOStreams
35136ac495dSmrg      or vectors, then you'll still need pieces from
35236ac495dSmrg      <code class="filename">libstdc++.a</code>.
35336ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.size"></a><a id="q-size"></a><p><strong>3.6.</strong></p></td><td align="left" valign="top"><p>
35436ac495dSmrg      This library is HUGE!
35536ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-size"></a></td><td align="left" valign="top"><p>
35636ac495dSmrg    Usually the size of libraries on disk isn't noticeable.  When a
35736ac495dSmrg    link editor (or simply <span class="quote">“<span class="quote">linker</span>”</span>) pulls things from a
35836ac495dSmrg    static archive library, only the necessary object files are copied
35936ac495dSmrg    into your executable, not the entire library.  Unfortunately, even
36036ac495dSmrg    if you only need a single function or variable from an object file,
36136ac495dSmrg    the entire object file is extracted.  (There's nothing unique to C++
36236ac495dSmrg    or libstdc++ about this; it's just common behavior, given here
36336ac495dSmrg    for background reasons.)
36436ac495dSmrg    </p><p>
36536ac495dSmrg    Some of the object files which make up
36636ac495dSmrg    <code class="filename">libstdc++.a</code> are rather large.
36736ac495dSmrg    If you create a statically-linked executable with
36836ac495dSmrg    <code class="option">-static</code>, those large object files are suddenly part
36936ac495dSmrg    of your executable.  Historically the best way around this was to
37036ac495dSmrg    only place a very few functions (often only a single one) in each
37136ac495dSmrg    source/object file; then extracting a single function is the same
37236ac495dSmrg    as extracting a single <code class="filename">.o</code> file.  For libstdc++ this
37336ac495dSmrg    is only possible to a certain extent; the object files in question contain
37436ac495dSmrg    template classes and template functions, pre-instantiated, and
37536ac495dSmrg    splitting those up causes severe maintenance headaches.
37636ac495dSmrg    </p><p>
37736ac495dSmrg    On supported platforms, libstdc++ takes advantage of garbage
37836ac495dSmrg    collection in the GNU linker to get a result similar to separating
37936ac495dSmrg    each symbol into a separate source and object files. On these platforms,
38036ac495dSmrg    GNU ld can place each function and variable into its own
38136ac495dSmrg    section in a <code class="filename">.o</code> file.  The GNU linker can then perform
38236ac495dSmrg    garbage collection on unused sections; this reduces the situation to only
38336ac495dSmrg    copying needed functions into the executable, as before, but all
38436ac495dSmrg    happens automatically.
38536ac495dSmrg    </p></td></tr><tr class="toc"><td align="left" valign="top" colspan="2"><dl><dt>4.1. <a href="faq.html#faq.other_compilers">
38636ac495dSmrg      Can libstdc++ be used with non-GNU compilers?
38736ac495dSmrg    </a></dt><dt>4.2. <a href="faq.html#faq.solaris_long_long">
38836ac495dSmrg      No 'long long' type on Solaris?
38936ac495dSmrg    </a></dt><dt>4.3. <a href="faq.html#faq.predefined">
39036ac495dSmrg      _XOPEN_SOURCE and _GNU_SOURCE are always defined?
39136ac495dSmrg    </a></dt><dt>4.4. <a href="faq.html#faq.darwin_ctype">
39236ac495dSmrg      Mac OS X ctype.h is broken! How can I fix it?
39336ac495dSmrg    </a></dt><dt>4.5. <a href="faq.html#faq.threads_i386">
39436ac495dSmrg      Threading is broken on i386?
39536ac495dSmrg    </a></dt><dt>4.6. <a href="faq.html#faq.atomic_mips">
39636ac495dSmrg      MIPS atomic operations
39736ac495dSmrg    </a></dt><dt>4.7. <a href="faq.html#faq.linux_glibc">
39836ac495dSmrg      Recent GNU/Linux glibc required?
39936ac495dSmrg    </a></dt><dt>4.8. <a href="faq.html#faq.freebsd_wchar">
40036ac495dSmrg      Can't use wchar_t/wstring on FreeBSD
40136ac495dSmrg    </a></dt></dl></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.other_compilers"></a><a id="q-other_compilers"></a><p><strong>4.1.</strong></p></td><td align="left" valign="top"><p>
40236ac495dSmrg      Can libstdc++ be used with non-GNU compilers?
40336ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-other_compilers"></a></td><td align="left" valign="top"><p>
40436ac495dSmrg    Perhaps.
40536ac495dSmrg    </p><p>
40636ac495dSmrg    Since the goal of ISO Standardization is for all C++
40736ac495dSmrg    implementations to be able to share code, libstdc++ should be
40836ac495dSmrg    usable under any ISO-compliant compiler, at least in theory.
40936ac495dSmrg    </p><p>
41036ac495dSmrg    However, the reality is that libstdc++ is targeted and optimized
41136ac495dSmrg    for GCC/G++. This means that often libstdc++ uses specific,
41236ac495dSmrg    non-standard features of G++ that are not present in older
41336ac495dSmrg    versions of proprietary compilers. It may take as much as a year or two
41436ac495dSmrg    after an official release of GCC that contains these features for
41536ac495dSmrg    proprietary tools to support these constructs.
41636ac495dSmrg    </p><p>
41736ac495dSmrg    Recent versions of libstdc++ are known to work with the Clang compiler.
41836ac495dSmrg    In the near past, specific released versions of libstdc++ have
41936ac495dSmrg    been known to work with versions of the EDG C++ compiler, and
42036ac495dSmrg    vendor-specific proprietary C++ compilers such as the Intel ICC
42136ac495dSmrg    C++ compiler.
42236ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.solaris_long_long"></a><a id="q-solaris_long_long"></a><p><strong>4.2.</strong></p></td><td align="left" valign="top"><p>
42336ac495dSmrg      No '<span class="type">long long</span>' type on Solaris?
424a2dc1f3fSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-solaris_long_long"></a></td><td align="left" valign="top"><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This answer is old and probably no longer be relevant.</p></div><p>
42536ac495dSmrg    By default we try to support the C99 <span class="type">long long</span> type.
42636ac495dSmrg    This requires that certain functions from your C library be present.
42736ac495dSmrg    </p><p>
42836ac495dSmrg    Up through release 3.0.2 the platform-specific tests performed by
42936ac495dSmrg    libstdc++ were too general, resulting in a conservative approach
43036ac495dSmrg    to enabling the <span class="type">long long</span> code paths. The most
43136ac495dSmrg    commonly reported platform affected was Solaris.
43236ac495dSmrg    </p><p>
43336ac495dSmrg    This has been fixed for libstdc++ releases greater than 3.0.3.
43436ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.predefined"></a><a id="q-predefined"></a><p><strong>4.3.</strong></p></td><td align="left" valign="top"><p>
43536ac495dSmrg      <code class="constant">_XOPEN_SOURCE</code> and <code class="constant">_GNU_SOURCE</code> are always defined?
43636ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-predefined"></a></td><td align="left" valign="top"><p>On Solaris, <span class="command"><strong>g++</strong></span> (but not <span class="command"><strong>gcc</strong></span>)
43736ac495dSmrg         always defines the preprocessor macro
43836ac495dSmrg	 <code class="constant">_XOPEN_SOURCE</code>.  On GNU/Linux, the same happens
43936ac495dSmrg         with <code class="constant">_GNU_SOURCE</code>.  (This is not an exhaustive list;
44036ac495dSmrg         other macros and other platforms are also affected.)
44136ac495dSmrg      </p><p>These macros are typically used in C library headers, guarding new
44236ac495dSmrg         versions of functions from their older versions.  The C++98 standard
44336ac495dSmrg         library includes the C standard library, but it requires the C90
44436ac495dSmrg         version, which for backwards-compatibility reasons is often not the
44536ac495dSmrg         default for many vendors.
44636ac495dSmrg      </p><p>More to the point, the C++ standard requires behavior which is only
44736ac495dSmrg         available on certain platforms after certain symbols are defined.
44836ac495dSmrg         Usually the issue involves I/O-related typedefs.  In order to
44936ac495dSmrg         ensure correctness, the compiler simply predefines those symbols.
45036ac495dSmrg      </p><p>Note that it's not enough to <code class="literal">#define</code> them only when the library is
45136ac495dSmrg         being built (during installation).  Since we don't have an 'export'
45236ac495dSmrg         keyword, much of the library exists as headers, which means that
45336ac495dSmrg         the symbols must also be defined as your programs are parsed and
45436ac495dSmrg         compiled.
45536ac495dSmrg      </p><p>To see which symbols are defined, look for
45636ac495dSmrg         <code class="varname">CPLUSPLUS_CPP_SPEC</code> in
45736ac495dSmrg         the gcc config headers for your target (and try changing them to
45836ac495dSmrg         see what happens when building complicated code).  You can also run
459*8feb0f0bSmrg         <span class="command"><strong>g++ -E -dM -x c++ /dev/null</strong></span> to display
46036ac495dSmrg         a list of predefined macros for any particular installation.
46136ac495dSmrg      </p><p>This has been discussed on the mailing lists
46236ac495dSmrg         <a class="link" href="http://gcc.gnu.org/cgi-bin/htsearch?method=and&amp;format=builtin-long&amp;sort=score&amp;words=_XOPEN_SOURCE+Solaris" target="_top">quite a bit</a>.
46336ac495dSmrg      </p><p>This method is something of a wart.  We'd like to find a cleaner
46436ac495dSmrg         solution, but nobody yet has contributed the time.
46536ac495dSmrg      </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.darwin_ctype"></a><a id="q-darwin_ctype"></a><p><strong>4.4.</strong></p></td><td align="left" valign="top"><p>
46636ac495dSmrg      Mac OS X <code class="filename">ctype.h</code> is broken! How can I fix it?
46736ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-darwin_ctype"></a></td><td align="left" valign="top"><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This answer is old and probably no longer be relevant.</p></div><p>
46836ac495dSmrg         This was a long-standing bug in the OS X support.  Fortunately, the
46936ac495dSmrg         <a class="link" href="http://gcc.gnu.org/ml/gcc/2002-03/msg00817.html" target="_top">patch</a>
47036ac495dSmrg	 was quite simple, and well-known.
47136ac495dSmrg      </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.threads_i386"></a><a id="q-threads_i386"></a><p><strong>4.5.</strong></p></td><td align="left" valign="top"><p>
47236ac495dSmrg      Threading is broken on i386?
47336ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-threads_i386"></a></td><td align="left" valign="top"><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This answer is old and probably no longer be relevant.</p></div><p>Support for atomic integer operations was broken on i386
47436ac495dSmrg         platforms.  The assembly code accidentally used opcodes that are
47536ac495dSmrg         only available on the i486 and later.  So if you configured GCC
47636ac495dSmrg         to target, for example, i386-linux, but actually used the programs
47736ac495dSmrg         on an i686, then you would encounter no problems.  Only when
47836ac495dSmrg         actually running the code on a i386 will the problem appear.
47936ac495dSmrg      </p><p>This is fixed in 3.2.2.
48036ac495dSmrg      </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.atomic_mips"></a><a id="q-atomic_mips"></a><p><strong>4.6.</strong></p></td><td align="left" valign="top"><p>
48136ac495dSmrg      MIPS atomic operations
48236ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-atomic_mips"></a></td><td align="left" valign="top"><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This answer is old and probably no longer be relevant.</p></div><p>
48336ac495dSmrg    The atomic locking routines for MIPS targets requires MIPS II
48436ac495dSmrg    and later.  A patch went in just after the 3.3 release to
48536ac495dSmrg    make mips* use the generic implementation instead.  You can also
48636ac495dSmrg    configure for mipsel-elf as a workaround.
48736ac495dSmrg    </p><p>
48836ac495dSmrg    The mips*-*-linux* port continues to use the MIPS II routines, and more
48936ac495dSmrg    work in this area is expected.
49036ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.linux_glibc"></a><a id="q-linux_glibc"></a><p><strong>4.7.</strong></p></td><td align="left" valign="top"><p>
49136ac495dSmrg      Recent GNU/Linux glibc required?
49236ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-linux_glibc"></a></td><td align="left" valign="top"><p>When running on GNU/Linux, libstdc++ 3.2.1 (shared library version
49336ac495dSmrg         5.0.1) and later uses localization and formatting code from the system
49436ac495dSmrg         C library (glibc) version 2.2.5 which contains necessary bugfixes.
49536ac495dSmrg         All GNU/Linux distros make more recent versions available now.
49636ac495dSmrg         libstdc++ 4.6.0 and later require glibc 2.3 or later for this
49736ac495dSmrg         localization and formatting code.
49836ac495dSmrg      </p><p>The guideline is simple:  the more recent the C++ library, the
49936ac495dSmrg         more recent the C library.  (This is also documented in the main
50036ac495dSmrg         GCC installation instructions.)
50136ac495dSmrg      </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.freebsd_wchar"></a><a id="q-freebsd_wchar"></a><p><strong>4.8.</strong></p></td><td align="left" valign="top"><p>
502a2dc1f3fSmrg      Can't use <span class="type">wchar_t</span>/<code class="classname">wstring</code> on FreeBSD
50336ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-freebsd_wchar"></a></td><td align="left" valign="top"><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This answer is old and probably no longer be relevant.</p></div><p>
50436ac495dSmrg    Older versions of FreeBSD's C library do not have sufficient
50536ac495dSmrg    support for wide character functions, and as a result the
50636ac495dSmrg    libstdc++ configury decides that <span class="type">wchar_t</span> support should be
50736ac495dSmrg    disabled. In addition, the libstdc++ platform checks that
50836ac495dSmrg    enabled <span class="type">wchar_t</span> were quite strict, and not granular
50936ac495dSmrg    enough to detect when the minimal support to
51036ac495dSmrg    enable <span class="type">wchar_t</span> and C++ library structures
51136ac495dSmrg    like <code class="classname">wstring</code> were present. This impacted Solaris,
51236ac495dSmrg    Darwin, and BSD variants, and is fixed in libstdc++ versions post 4.1.0.
51336ac495dSmrg    </p><p>
51436ac495dSmrg    </p></td></tr><tr class="toc"><td align="left" valign="top" colspan="2"><dl><dt>5.1. <a href="faq.html#faq.what_works">
51536ac495dSmrg      What works already?
51636ac495dSmrg    </a></dt><dt>5.2. <a href="faq.html#faq.standard_bugs">
51736ac495dSmrg      Bugs in the ISO C++ language or library specification
51836ac495dSmrg    </a></dt><dt>5.3. <a href="faq.html#faq.compiler_bugs">
51936ac495dSmrg      Bugs in the compiler (gcc/g++) and not libstdc++
52036ac495dSmrg    </a></dt></dl></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.what_works"></a><a id="q-what_works"></a><p><strong>5.1.</strong></p></td><td align="left" valign="top"><p>
52136ac495dSmrg      What works already?
52236ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-what_works"></a></td><td align="left" valign="top"><p>
52336ac495dSmrg    Short answer: Pretty much everything <span class="emphasis"><em>works</em></span>
52436ac495dSmrg    except for some corner cases.  Support for localization
52536ac495dSmrg    in <code class="classname">locale</code> may be incomplete on some non-GNU
52636ac495dSmrg    platforms. Also dependent on the underlying platform is support
52736ac495dSmrg    for <span class="type">wchar_t</span> and <span class="type">long long</span> specializations,
52836ac495dSmrg    and details of thread support.
52936ac495dSmrg    </p><p>
53036ac495dSmrg    Long answer: See the implementation status pages for
53136ac495dSmrg    <a class="link" href="manual/status.html#status.iso.1998" title="C++ 1998/2003">C++98</a>,
53236ac495dSmrg    <a class="link" href="manual/status.html#status.iso.tr1" title="C++ TR1">TR1</a>,
53336ac495dSmrg    <a class="link" href="manual/status.html#status.iso.2011" title="C++ 2011">C++11</a>,
53436ac495dSmrg    <a class="link" href="manual/status.html#status.iso.2014" title="C++ 2014">C++14</a>, and
53536ac495dSmrg    <a class="link" href="manual/status.html#status.iso.2017" title="C++ 2017">C++17</a>.
53636ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.standard_bugs"></a><a id="q-standard_bugs"></a><p><strong>5.2.</strong></p></td><td align="left" valign="top"><p>
53736ac495dSmrg      Bugs in the ISO C++ language or library specification
53836ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-standard_bugs"></a></td><td align="left" valign="top"><p>
53936ac495dSmrg    Unfortunately, there are some.
54036ac495dSmrg    </p><p>
54136ac495dSmrg    For those people who are not part of the ISO Library Group
54236ac495dSmrg    (i.e., nearly all of us needing to read this page in the first
54336ac495dSmrg    place), a public list of the library defects is occasionally
54436ac495dSmrg    published on <a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/" target="_top">the WG21
54536ac495dSmrg    website</a>.
546a2dc1f3fSmrg    Many of these issues have resulted in
547a2dc1f3fSmrg    <a class="link" href="manual/bugs.html#manual.intro.status.bugs.iso" title="Standard Bugs">code changes in libstdc++</a>.
54836ac495dSmrg    </p><p>
54936ac495dSmrg    If you think you've discovered a new bug that is not listed,
55036ac495dSmrg    please post a message describing your problem to the author of
55136ac495dSmrg    the library issues list.
55236ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.compiler_bugs"></a><a id="q-compiler_bugs"></a><p><strong>5.3.</strong></p></td><td align="left" valign="top"><p>
55336ac495dSmrg      Bugs in the compiler (gcc/g++) and not libstdc++
55436ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-compiler_bugs"></a></td><td align="left" valign="top"><p>
55536ac495dSmrg    On occasion, the compiler is wrong. Please be advised that this
55636ac495dSmrg    happens much less often than one would think, and avoid jumping to
55736ac495dSmrg    conclusions.
55836ac495dSmrg    </p><p>
55936ac495dSmrg    First, examine the ISO C++ standard. Second, try another compiler
56036ac495dSmrg    or an older version of the GNU compilers. Third, you can find more
56136ac495dSmrg    information on the libstdc++ and the GCC mailing lists: search
56236ac495dSmrg    these lists with terms describing your issue.
56336ac495dSmrg    </p><p>
56436ac495dSmrg    Before reporting a bug, please examine the
565a2dc1f3fSmrg    <a class="link" href="https://gcc.gnu.org/bugs/" target="_top">bugs database</a>, with the
566a2dc1f3fSmrg    component set to <span class="quote">“<span class="quote">c++</span>”</span>.
56736ac495dSmrg    </p></td></tr><tr class="toc"><td align="left" valign="top" colspan="2"><dl><dt>6.1. <a href="faq.html#faq.stream_reopening_fails">
56836ac495dSmrg      Reopening a stream fails
56936ac495dSmrg    </a></dt><dt>6.2. <a href="faq.html#faq.wefcxx_verbose">
57036ac495dSmrg      -Weffc++ complains too much
57136ac495dSmrg    </a></dt><dt>6.3. <a href="faq.html#faq.ambiguous_overloads">
57236ac495dSmrg      Ambiguous overloads after including an old-style header
57336ac495dSmrg    </a></dt><dt>6.4. <a href="faq.html#faq.v2_headers">
57436ac495dSmrg      The g++-3 headers are not ours
57536ac495dSmrg    </a></dt><dt>6.5. <a href="faq.html#faq.boost_concept_checks">
57636ac495dSmrg      Errors about *Concept and
57736ac495dSmrg      constraints in the STL
57836ac495dSmrg    </a></dt><dt>6.6. <a href="faq.html#faq.dlopen_crash">
57936ac495dSmrg      Program crashes when using library code in a
58036ac495dSmrg      dynamically-loaded library
58136ac495dSmrg    </a></dt><dt>6.7. <a href="faq.html#faq.memory_leaks">
582a2dc1f3fSmrg      “Memory leaks” in libstdc++
58336ac495dSmrg    </a></dt><dt>6.8. <a href="faq.html#faq.list_size_on">
58436ac495dSmrg      list::size() is O(n)!
58536ac495dSmrg    </a></dt><dt>6.9. <a href="faq.html#faq.easy_to_fix">
58636ac495dSmrg      Aw, that's easy to fix!
58736ac495dSmrg    </a></dt></dl></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.stream_reopening_fails"></a><a id="q-stream_reopening_fails"></a><p><strong>6.1.</strong></p></td><td align="left" valign="top"><p>
58836ac495dSmrg      Reopening a stream fails
589a2dc1f3fSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-stream_reopening_fails"></a></td><td align="left" valign="top"><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This answer is old and probably no longer be relevant.</p></div><p>
590a2dc1f3fSmrg    Prior to GCC 4.0 this was one of the most-reported non-bug reports.
591a2dc1f3fSmrg    Executing a sequence like this would fail:
59236ac495dSmrg    </p><pre class="programlisting">
59336ac495dSmrg    #include &lt;fstream&gt;
59436ac495dSmrg    ...
59536ac495dSmrg    std::fstream  fs("a_file");
59636ac495dSmrg    // .
59736ac495dSmrg    // . do things with fs...
59836ac495dSmrg    // .
59936ac495dSmrg    fs.close();
60036ac495dSmrg    fs.open("a_new_file");
60136ac495dSmrg    </pre><p>
602a2dc1f3fSmrg    All operations on the re-opened <code class="varname">fs</code> would fail, or at
603a2dc1f3fSmrg    least act very strangely, especially if <code class="varname">fs</code> reached the
604a2dc1f3fSmrg    EOF state on the previous file.
605a2dc1f3fSmrg    The original C++98 standard did not specify behavior in this case, and
606a2dc1f3fSmrg    the <a class="link" href="manual/bugs.html#manual.bugs.dr22">resolution of DR #22</a> was to
607a2dc1f3fSmrg    leave the state flags unchanged on a successful call to
608a2dc1f3fSmrg    <code class="function">open()</code>.
609a2dc1f3fSmrg    You had to insert a call to <code class="function">fs.clear()</code> between the
610a2dc1f3fSmrg    calls to <code class="function">close()</code> and <code class="function">open()</code>,
611a2dc1f3fSmrg    and then everything will work as expected.
612a2dc1f3fSmrg    <span class="emphasis"><em>Update:</em></span> For GCC 4.0 we implemented the resolution
613a2dc1f3fSmrg    of <a class="link" href="manual/bugs.html#manual.bugs.dr409">DR #409</a> and
614a2dc1f3fSmrg    <code class="function">open()</code>
615a2dc1f3fSmrg    now calls <code class="function">clear()</code> on success.
61636ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.wefcxx_verbose"></a><a id="q-wefcxx_verbose"></a><p><strong>6.2.</strong></p></td><td align="left" valign="top"><p>
61736ac495dSmrg      -Weffc++ complains too much
61836ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-wefcxx_verbose"></a></td><td align="left" valign="top"><p>
61936ac495dSmrg    Many warnings are emitted when <code class="option">-Weffc++</code> is used.  Making
62036ac495dSmrg    libstdc++ <code class="option">-Weffc++</code>-clean is not a goal of the project,
62136ac495dSmrg    for a few reasons.  Mainly, that option tries to enforce
62236ac495dSmrg    object-oriented programming, while the Standard Library isn't
623a2dc1f3fSmrg    necessarily trying to be OO. The option also enforces outdated guidelines
624a2dc1f3fSmrg    from old editions of the books, and the advice isn't all relevant to
625a2dc1f3fSmrg    modern C++ (especially C++11 and later).
62636ac495dSmrg    </p><p>
62736ac495dSmrg    We do, however, try to have libstdc++ sources as clean as possible. If
62836ac495dSmrg    you see some simple changes that pacify <code class="option">-Weffc++</code>
62936ac495dSmrg    without other drawbacks, send us a patch.
63036ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.ambiguous_overloads"></a><a id="q-ambiguous_overloads"></a><p><strong>6.3.</strong></p></td><td align="left" valign="top"><p>
63136ac495dSmrg      Ambiguous overloads after including an old-style header
63236ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-ambiguous_overloads"></a></td><td align="left" valign="top"><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This answer is old and probably no longer be relevant.</p></div><p>
63336ac495dSmrg    Another problem is the <code class="literal">rel_ops</code> namespace and the template
63436ac495dSmrg    comparison operator functions contained therein.  If they become
63536ac495dSmrg    visible in the same namespace as other comparison functions
636a2dc1f3fSmrg    (e.g., <span class="quote">“<span class="quote">using</span>”</span> them and the
637a2dc1f3fSmrg    <code class="filename">&lt;iterator&gt;</code> header),
63836ac495dSmrg    then you will suddenly be faced with huge numbers of ambiguity
639a2dc1f3fSmrg    errors.  This was discussed on the mailing list; Nathan Myers
64036ac495dSmrg    <a class="link" href="http://gcc.gnu.org/ml/libstdc++/2001-01/msg00247.html" target="_top">sums
64136ac495dSmrg      things up here</a>.  The collisions with vector/string iterator
64236ac495dSmrg    types have been fixed for 3.1.
64336ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.v2_headers"></a><a id="q-v2_headers"></a><p><strong>6.4.</strong></p></td><td align="left" valign="top"><p>
64436ac495dSmrg      The g++-3 headers are <span class="emphasis"><em>not ours</em></span>
645a2dc1f3fSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-v2_headers"></a></td><td align="left" valign="top"><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This answer is old and probably no longer be relevant.</p></div><p>
64636ac495dSmrg	If you are using headers in
64736ac495dSmrg	<code class="filename">${prefix}/include/g++-3</code>, or if
64836ac495dSmrg	the installed library's name looks like
64936ac495dSmrg	<code class="filename">libstdc++-2.10.a</code> or
65036ac495dSmrg	<code class="filename">libstdc++-libc6-2.10.so</code>, then
65136ac495dSmrg	you are using the old libstdc++-v2 library, which is non-standard and
65236ac495dSmrg	unmaintained.  Do not report problems with -v2 to the -v3
65336ac495dSmrg	mailing list.
65436ac495dSmrg      </p><p>
65536ac495dSmrg	For GCC versions 3.0 and 3.1 the libstdc++ header files are installed in
65636ac495dSmrg	<code class="filename">${prefix}/include/g++-v3</code>
65736ac495dSmrg	(see the 'v'?).  Starting with version 3.2 the headers are installed in
65836ac495dSmrg	<code class="filename">${prefix}/include/c++/${version}</code>
65936ac495dSmrg	as this prevents headers from previous versions being found by mistake.
66036ac495dSmrg      </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.boost_concept_checks"></a><a id="q-boost_concept_checks"></a><p><strong>6.5.</strong></p></td><td align="left" valign="top"><p>
66136ac495dSmrg      Errors about <span class="emphasis"><em>*Concept</em></span> and
66236ac495dSmrg      <span class="emphasis"><em>constraints</em></span> in the STL
66336ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-boost_concept_checks"></a></td><td align="left" valign="top"><p>
66436ac495dSmrg    If you see compilation errors containing messages about
66536ac495dSmrg    <span class="errortext">foo Concept</span> and something to do with a
66636ac495dSmrg    <span class="errortext">constraints</span> member function, then most
66736ac495dSmrg    likely you have violated one of the requirements for types used
66836ac495dSmrg    during instantiation of template containers and functions.  For
66936ac495dSmrg    example, EqualityComparableConcept appears if your types must be
67036ac495dSmrg    comparable with == and you have not provided this capability (a
67136ac495dSmrg    typo, or wrong visibility, or you just plain forgot, etc).
67236ac495dSmrg    </p><p>
67336ac495dSmrg    More information, including how to optionally enable/disable the
67436ac495dSmrg    checks, is available in the
67536ac495dSmrg    <a class="link" href="manual/concept_checking.html" title="Concept Checking">Diagnostics</a>.
67636ac495dSmrg    chapter of the manual.
67736ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.dlopen_crash"></a><a id="q-dlopen_crash"></a><p><strong>6.6.</strong></p></td><td align="left" valign="top"><p>
67836ac495dSmrg      Program crashes when using library code in a
67936ac495dSmrg      dynamically-loaded library
68036ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-dlopen_crash"></a></td><td align="left" valign="top"><p>
68136ac495dSmrg    If you are using the C++ library across dynamically-loaded
68236ac495dSmrg    objects, make certain that you are passing the correct options
68336ac495dSmrg    when compiling and linking:
68436ac495dSmrg    </p><div class="literallayout"><p><br />
68536ac495dSmrg    Compile your library components:<br />
68636ac495dSmrg    <span class="command"><strong>g++ -fPIC -c a.cc</strong></span><br />
68736ac495dSmrg    <span class="command"><strong>g++ -fPIC -c b.cc</strong></span><br />
68836ac495dSmrg    ...<br />
68936ac495dSmrg    <span class="command"><strong>g++ -fPIC -c z.cc</strong></span><br />
69036ac495dSmrg<br />
69136ac495dSmrg    Create your library:<br />
69236ac495dSmrg    <span class="command"><strong>g++ -fPIC -shared -rdynamic -o libfoo.so a.o b.o ... z.o</strong></span><br />
69336ac495dSmrg<br />
69436ac495dSmrg    Link the executable:<br />
69536ac495dSmrg    <span class="command"><strong>g++ -fPIC -rdynamic -o foo ... -L. -lfoo -ldl</strong></span><br />
69636ac495dSmrg    </p></div></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.memory_leaks"></a><a id="q-memory_leaks"></a><p><strong>6.7.</strong></p></td><td align="left" valign="top"><p>
697a2dc1f3fSmrg      <span class="quote">“<span class="quote">Memory leaks</span>”</span> in libstdc++
69836ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-memory_leaks"></a></td><td align="left" valign="top"><p>
699a2dc1f3fSmrg    Since GCC 5.1.0, libstdc++ automatically allocates a pool
700a2dc1f3fSmrg    of a few dozen kilobytes on startup. This pool is used to ensure it's
701a2dc1f3fSmrg    possible to throw exceptions (such as <code class="classname">bad_alloc</code>)
702a2dc1f3fSmrg    even when <code class="code">malloc</code> is unable to allocate any more memory.
703a2dc1f3fSmrg    With some versions of <a class="link" href="http://valgrind.org/" target="_top"><span class="command"><strong>valgrind</strong></span></a>
704a2dc1f3fSmrg    this pool will be shown as "still reachable" when the process exits, e.g.
705a2dc1f3fSmrg    <code class="code">still reachable: 72,704 bytes in 1 blocks</code>.
706a2dc1f3fSmrg    This memory is not a leak, because it's still in use by libstdc++,
707a2dc1f3fSmrg    and the memory will be returned to the OS when the process exits.
708a2dc1f3fSmrg    Later versions of <span class="command"><strong>valgrind</strong></span> know how to free this
709a2dc1f3fSmrg    pool as the process exits, and so won't show any "still reachable" memory.
710a2dc1f3fSmrg    </p><p>
711a2dc1f3fSmrg    In the past, a few people reported that the standard containers appear
71236ac495dSmrg    to leak memory when tested with memory checkers such as
71336ac495dSmrg    <a class="link" href="http://valgrind.org/" target="_top"><span class="command"><strong>valgrind</strong></span></a>.
714a2dc1f3fSmrg    Under some (non-default) configurations the library's allocators keep
715a2dc1f3fSmrg    free memory in a
716a2dc1f3fSmrg    pool for later reuse, rather than deallocating it with <code class="code">delete</code>
717a2dc1f3fSmrg    Although this memory is always reachable by the library and is never
71836ac495dSmrg    lost, memory debugging tools can report it as a leak.  If you
71936ac495dSmrg    want to test the library for memory leaks please read
72036ac495dSmrg    <a class="link" href="manual/debug.html#debug.memory" title="Memory Leak Hunting">Tips for memory leak hunting</a>
72136ac495dSmrg    first.
72236ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.list_size_on"></a><a id="q-list_size_on"></a><p><strong>6.8.</strong></p></td><td align="left" valign="top"><p>
723a2dc1f3fSmrg      <code class="code">list::size()</code> is O(n)!
72436ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-list_size_on"></a></td><td align="left" valign="top"><p>
72536ac495dSmrg    See
72636ac495dSmrg    the <a class="link" href="manual/containers.html" title="Chapter 9.  Containers">Containers</a>
72736ac495dSmrg    chapter.
72836ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.easy_to_fix"></a><a id="q-easy_to_fix"></a><p><strong>6.9.</strong></p></td><td align="left" valign="top"><p>
72936ac495dSmrg      Aw, that's easy to fix!
73036ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-easy_to_fix"></a></td><td align="left" valign="top"><p>
73136ac495dSmrg    If you have found a bug in the library and you think you have
73236ac495dSmrg    a working fix, then send it in!  The main GCC site has a page
73336ac495dSmrg    on <a class="link" href="http://gcc.gnu.org/contribute.html" target="_top">submitting
73436ac495dSmrg    patches</a> that covers the procedure, but for libstdc++ you
73536ac495dSmrg    should also send the patch to our mailing list in addition to
73636ac495dSmrg    the GCC patches mailing list.  The libstdc++
73736ac495dSmrg    <a class="link" href="manual/appendix_contributing.html" title="Appendix A.  Contributing">contributors' page</a>
73836ac495dSmrg    also talks about how to submit patches.
73936ac495dSmrg    </p><p>
74036ac495dSmrg    In addition to the description, the patch, and the ChangeLog
74136ac495dSmrg    entry, it is a Good Thing if you can additionally create a small
74236ac495dSmrg    test program to test for the presence of the bug that your patch
74336ac495dSmrg    fixes.  Bugs have a way of being reintroduced; if an old bug
74436ac495dSmrg    creeps back in, it will be caught immediately by the testsuite -
74536ac495dSmrg    but only if such a test exists.
74636ac495dSmrg    </p></td></tr><tr class="toc"><td align="left" valign="top" colspan="2"><dl><dt>7.1. <a href="faq.html#faq.iterator_as_pod">
747a2dc1f3fSmrg      string::iterator is not char*;
748a2dc1f3fSmrg      vector&lt;T&gt;::iterator is not T*
74936ac495dSmrg    </a></dt><dt>7.2. <a href="faq.html#faq.what_is_next">
75036ac495dSmrg      What's next after libstdc++?
75136ac495dSmrg    </a></dt><dt>7.3. <a href="faq.html#faq.sgi_stl">
75236ac495dSmrg      What about the STL from SGI?
75336ac495dSmrg    </a></dt><dt>7.4. <a href="faq.html#faq.extensions_and_backwards_compat">
75436ac495dSmrg      Extensions and Backward Compatibility
75536ac495dSmrg    </a></dt><dt>7.5. <a href="faq.html#faq.tr1_support">
75636ac495dSmrg      Does libstdc++ support TR1?
75736ac495dSmrg    </a></dt><dt>7.6. <a href="faq.html#faq.get_iso_cxx">How do I get a copy of the ISO C++ Standard?
75836ac495dSmrg    </a></dt><dt>7.7. <a href="faq.html#faq.what_is_abi">
75936ac495dSmrg      What's an ABI and why is it so messy?
76036ac495dSmrg    </a></dt><dt>7.8. <a href="faq.html#faq.size_equals_capacity">
76136ac495dSmrg      How do I make std::vector&lt;T&gt;::capacity() == std::vector&lt;T&gt;::size?
76236ac495dSmrg    </a></dt></dl></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.iterator_as_pod"></a><a id="faq.iterator_as_pod_q"></a><p><strong>7.1.</strong></p></td><td align="left" valign="top"><p>
763a2dc1f3fSmrg      <code class="classname">string::iterator</code> is not <code class="code">char*</code>;
764a2dc1f3fSmrg      <code class="classname">vector&lt;T&gt;::iterator</code> is not <code class="code">T*</code>
76536ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="faq.iterator_as_pod_a"></a></td><td align="left" valign="top"><p>
76636ac495dSmrg    If you have code that depends on container&lt;T&gt; iterators
76736ac495dSmrg    being implemented as pointer-to-T, your code is broken. It's
76836ac495dSmrg    considered a feature, not a bug, that libstdc++ points this out.
76936ac495dSmrg    </p><p>
77036ac495dSmrg    While there are arguments for iterators to be implemented in
77136ac495dSmrg    that manner, A) they aren't very good ones in the long term,
77236ac495dSmrg    and B) they were never guaranteed by the Standard anyway.  The
77336ac495dSmrg    type-safety achieved by making iterators a real class rather
77436ac495dSmrg    than a typedef for <span class="type">T*</span> outweighs nearly all opposing
77536ac495dSmrg    arguments.
77636ac495dSmrg    </p><p>
777a2dc1f3fSmrg    Code which does assume that a vector/string iterator <code class="varname">i</code>
77836ac495dSmrg    is a pointer can often be fixed by changing <code class="varname">i</code> in
779a2dc1f3fSmrg    certain expressions to <code class="varname">&amp;*i</code>.
78036ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.what_is_next"></a><a id="q-what_is_next"></a><p><strong>7.2.</strong></p></td><td align="left" valign="top"><p>
78136ac495dSmrg      What's next after libstdc++?
78236ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-what_is_next"></a></td><td align="left" valign="top"><p>
783a2dc1f3fSmrg	The goal of libstdc++ is to produce a
784a2dc1f3fSmrg	fully-compliant, fully-portable Standard Library.
785a2dc1f3fSmrg	While the C++ Standard continues to evolve the libstdc++ will
786a2dc1f3fSmrg        continue to track it.
78736ac495dSmrg      </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.sgi_stl"></a><a id="q-sgi_stl"></a><p><strong>7.3.</strong></p></td><td align="left" valign="top"><p>
78836ac495dSmrg      What about the STL from SGI?
78936ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-sgi_stl"></a></td><td align="left" valign="top"><p>
790a2dc1f3fSmrg    The STL (Standard Template Library) was the inspiration for large chunks
791a2dc1f3fSmrg    of the C++ Standard Library, but the terms are not interchangeable and
792a2dc1f3fSmrg    they don't mean the same thing. The C++ Standard Library includes lots of
793a2dc1f3fSmrg    things that didn't come from the STL, and some of them aren't even
794a2dc1f3fSmrg    templates, such as <code class="classname">std::locale</code> and
795a2dc1f3fSmrg    <code class="classname">std::thread</code>.
796a2dc1f3fSmrg    </p><p>
797a2dc1f3fSmrg    Libstdc++-v3 incorporates a lot of code from
798a2dc1f3fSmrg    <a class="link" href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/" target="_top">the SGI STL</a>
799a2dc1f3fSmrg    (the final merge was from
800a2dc1f3fSmrg    <a class="link" href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/whats_new.html" target="_top">release 3.3</a>).
801a2dc1f3fSmrg    The code in libstdc++ contains many fixes and changes compared to the
802a2dc1f3fSmrg    original SGI code.
80336ac495dSmrg    </p><p>
80436ac495dSmrg    In particular, <code class="classname">string</code> is not from SGI and makes no
805a2dc1f3fSmrg    use of their "rope" class (although that is included as an optional
806a2dc1f3fSmrg    extension), neither is <code class="classname">valarray</code> nor some others.
807a2dc1f3fSmrg    Classes like <code class="classname">vector&lt;&gt;</code> were from SGI, but have
808a2dc1f3fSmrg    been extensively modified.
80936ac495dSmrg    </p><p>
81036ac495dSmrg    More information on the evolution of libstdc++ can be found at the
81136ac495dSmrg    <a class="link" href="manual/api.html" title="API Evolution and Deprecation History">API
81236ac495dSmrg    evolution</a>
81336ac495dSmrg    and <a class="link" href="manual/backwards.html" title="Backwards Compatibility">backwards
81436ac495dSmrg    compatibility</a> documentation.
81536ac495dSmrg    </p><p>
816*8feb0f0bSmrg    The <a class="link" href="https://web.archive.org/web/20171104092813/http://www.sgi.com/tech/stl/FAQ.html" target="_top">FAQ</a>
81736ac495dSmrg    for SGI's STL is still recommended reading.
81836ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.extensions_and_backwards_compat"></a><a id="q-extensions_and_backwards_compat"></a><p><strong>7.4.</strong></p></td><td align="left" valign="top"><p>
81936ac495dSmrg      Extensions and Backward Compatibility
82036ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-extensions_and_backwards_compat"></a></td><td align="left" valign="top"><p>
82136ac495dSmrg      See the <a class="link" href="manual/backwards.html" title="Backwards Compatibility">link</a> on backwards compatibility and <a class="link" href="manual/api.html" title="API Evolution and Deprecation History">link</a> on evolution.
82236ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.tr1_support"></a><a id="q-tr1_support"></a><p><strong>7.5.</strong></p></td><td align="left" valign="top"><p>
82336ac495dSmrg      Does libstdc++ support TR1?
82436ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-tr1_support"></a></td><td align="left" valign="top"><p>
82536ac495dSmrg    Yes.
82636ac495dSmrg    </p><p>
827a2dc1f3fSmrg    The C++ Standard Library
82836ac495dSmrg    <a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf" target="_top">
829a2dc1f3fSmrg    Technical Report 1</a> added many new features to the library.
83036ac495dSmrg    </p><p>
831a2dc1f3fSmrg    The implementation status of TR1 in libstdc++ can be tracked
832a2dc1f3fSmrg    <a class="link" href="manual/status.html#status.iso.tr1" title="C++ TR1">on the TR1 status page</a>.
833a2dc1f3fSmrg    </p><p>
834a2dc1f3fSmrg    New code should probably not use TR1, because almost everything in it has
835a2dc1f3fSmrg    been added to the main C++ Standard Library (usually with significant
836a2dc1f3fSmrg    improvements).
837a2dc1f3fSmrg    The TR1 implementation in libstdc++ is no longer actively maintained.
83836ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.get_iso_cxx"></a><a id="q-get_iso_cxx"></a><p><strong>7.6.</strong></p></td><td align="left" valign="top"><p>How do I get a copy of the ISO C++ Standard?
83936ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-get_iso_cxx"></a></td><td align="left" valign="top"><p>
84036ac495dSmrg    Please refer to the <a class="link" href="manual/appendix_contributing.html" title="Appendix A.  Contributing">Contributing</a>
84136ac495dSmrg    section in our manual.
84236ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.what_is_abi"></a><a id="q-what_is_abi"></a><p><strong>7.7.</strong></p></td><td align="left" valign="top"><p>
84336ac495dSmrg      What's an ABI and why is it so messy?
84436ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-what_is_abi"></a></td><td align="left" valign="top"><p>
84536ac495dSmrg    <acronym class="acronym">ABI</acronym> stands for <span class="quote">“<span class="quote">Application Binary
84636ac495dSmrg    Interface</span>”</span>.  Conventionally, it refers to a great
84736ac495dSmrg    mass of details about how arguments are arranged on the call
84836ac495dSmrg    stack and/or in registers, and how various types are arranged
84936ac495dSmrg    and padded in structs.  A single CPU design may suffer
85036ac495dSmrg    multiple ABIs designed by different development tool vendors
85136ac495dSmrg    who made different choices, or even by the same vendor for
85236ac495dSmrg    different target applications or compiler versions.  In ideal
85336ac495dSmrg    circumstances the CPU designer presents one ABI and all the
85436ac495dSmrg    OSes and compilers use it.  In practice every ABI omits
85536ac495dSmrg    details that compiler implementers (consciously or
85636ac495dSmrg    accidentally) must choose for themselves.
85736ac495dSmrg    </p><p>
85836ac495dSmrg    That ABI definition suffices for compilers to generate code so a
85936ac495dSmrg    program can interact safely with an OS and its lowest-level libraries.
86036ac495dSmrg    Users usually want an ABI to encompass more detail, allowing libraries
86136ac495dSmrg    built with different compilers (or different releases of the same
86236ac495dSmrg    compiler!) to be linked together.  For C++, this includes many more
86336ac495dSmrg    details than for C, and most CPU designers (for good reasons elaborated
86436ac495dSmrg    below) have not stepped up to publish C++ ABIs.  Such an ABI has been
86536ac495dSmrg    defined for the Itanium architecture (see
86636ac495dSmrg    <a class="link" href="https://itanium-cxx-abi.github.io/cxx-abi/" target="_top">C++
86736ac495dSmrg    ABI for Itanium</a>) and that is used by G++ and other compilers
86836ac495dSmrg    as the de facto standard ABI on many common architectures (including x86).
86936ac495dSmrg    G++ can also use the ARM architecture's EABI, for embedded
87036ac495dSmrg    systems relying only on a <span class="quote">“<span class="quote">free-standing implementation</span>”</span> that
87136ac495dSmrg    doesn't include (much of) the standard library, and the GNU EABI for
87236ac495dSmrg    hosted implementations on ARM.  Those ABIs cover low-level details
87336ac495dSmrg    such as virtual function implementation, struct inheritance layout,
87436ac495dSmrg    name mangling, and exception handling.
87536ac495dSmrg   </p><p>
87636ac495dSmrg    A useful C++ ABI must also incorporate many details of the standard
87736ac495dSmrg    library implementation.  For a C ABI, the layouts of a few structs
87836ac495dSmrg    (such as <span class="type">FILE</span>, <span class="type">stat</span>, <span class="type">jmpbuf</span>,
87936ac495dSmrg    and the like) and a few macros suffice.
88036ac495dSmrg    For C++, the details include the complete set of names of functions
88136ac495dSmrg    and types used, the offsets of class members and virtual functions,
88236ac495dSmrg    and the actual definitions of all inlines.  C++ exposes many more
88336ac495dSmrg    library details to the caller than C does.  It makes defining
88436ac495dSmrg    a complete ABI a much bigger undertaking, and requires not just
88536ac495dSmrg    documenting library implementation details, but carefully designing
88636ac495dSmrg    those details so that future bug fixes and optimizations don't
88736ac495dSmrg    force breaking the ABI.
88836ac495dSmrg    </p><p>
88936ac495dSmrg    There are ways to help isolate library implementation details from the
89036ac495dSmrg    ABI, but they trade off against speed.  Library details used in inner
89136ac495dSmrg    loops (e.g., <code class="function">getchar</code>) must be exposed and frozen for
89236ac495dSmrg    all time, but many others may reasonably be kept hidden from user code,
89336ac495dSmrg    so they may later be changed.  Deciding which, and implementing
89436ac495dSmrg    the decisions, must happen before you can reasonably document a
89536ac495dSmrg    candidate C++ ABI that encompasses the standard library.
89636ac495dSmrg    </p></td></tr><tr class="question"><td align="left" valign="top"><a id="faq.size_equals_capacity"></a><a id="q-size_equals_capacity"></a><p><strong>7.8.</strong></p></td><td align="left" valign="top"><p>
897a2dc1f3fSmrg      How do I make <code class="code">std::vector&lt;T&gt;::capacity() == std::vector&lt;T&gt;::size</code>?
89836ac495dSmrg    </p></td></tr><tr class="answer"><td align="left" valign="top"><a id="a-size_equals_capacity"></a></td><td align="left" valign="top"><p>
899a2dc1f3fSmrg    Since C++11 just call the <code class="function">shrink_to_fit()</code> member
900a2dc1f3fSmrg    function.
901a2dc1f3fSmrg    </p><p>
902a2dc1f3fSmrg    Before C++11, the standard idiom for deallocating a
903a2dc1f3fSmrg    <code class="classname">vector&lt;T&gt;</code>'s
904a2dc1f3fSmrg    unused memory was to create a temporary copy of the vector and swap their
90536ac495dSmrg    contents, e.g. for <code class="classname">vector&lt;T&gt; v</code>
90636ac495dSmrg    </p><div class="literallayout"><p><br />
90736ac495dSmrg     std::vector&lt;T&gt;(v).swap(v);<br />
90836ac495dSmrg    </p></div><p>
90936ac495dSmrg    The copy will take O(n) time and the swap is constant time.
91036ac495dSmrg    </p><p>
91136ac495dSmrg    See <a class="link" href="manual/strings.html#strings.string.shrink" title="Shrink to Fit">Shrink-to-fit
91236ac495dSmrg    strings</a> for a similar solution for strings.
91336ac495dSmrg    </p></td></tr></tbody></table></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="bk03.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="bk03.html">Up</a></td><td width="40%" align="right"> </td></tr><tr><td width="40%" align="left" valign="top"> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> </td></tr></table></div></body></html>