1 <?xml version="1.0" encoding="ISO-8859-1"?>
3 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
8 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
9 <meta name="KEYWORDS" content="libstdc++, libstdc++-v3, GCC, g++, libg++, STL" />
10 <meta name="DESCRIPTION" content="FAQ for the GNU libstdc++ effort." />
11 <title>libstdc++-v3 FAQ</title>
12 <link rel="StyleSheet" href="../lib3styles.css" />
14 ** Locations of "the most recent snapshot is the Nth" text are
15 ** answers 1_1, 1_4, 4_1.
20 <h1 class="centered">libstdc++ Frequently Asked Questions</h1>
22 <p class="fineprint"><em>
23 The latest version of this document is always available at
24 <a href="http://gcc.gnu.org/onlinedocs/libstdc++/faq/">
25 http://gcc.gnu.org/onlinedocs/libstdc++/faq/</a>. The main documentation
27 <a href="http://gcc.gnu.org/onlinedocs/libstdc++/documentation.html">
28 http://gcc.gnu.org/onlinedocs/libstdc++/documentation.html</a>.
32 To the <a href="http://gcc.gnu.org/libstdc++/">libstdc++-v3 homepage</a>.
35 <!-- ####################################################### -->
39 <li><a href="#1_0">General Information</a>
40 <!-- I suspect these will mostly be links to/into existing documents. -->
42 <li><a href="#1_1">What is libstdc++-v3?</a> </li>
43 <li><a href="#1_2">Why should I use libstdc++?</a> </li>
44 <li><a href="#1_3">Who's in charge of it?</a> </li>
45 <li><a href="#1_4">How do I get libstdc++?</a> </li>
46 <li><a href="#1_5">When is libstdc++ going to be finished?</a> </li>
47 <li><a href="#1_6">How do I contribute to the effort?</a> </li>
48 <li><a href="#1_7">What happened to libg++? I need that!</a> </li>
49 <li><a href="#1_8">What if I have more questions?</a> </li>
50 <li><a href="#1_9">What are the license terms for libstdc++-v3?</a> </li>
54 <li><a href="#2_0">Installation</a>
56 <li><a href="#2_1">How do I install libstdc++-v3?</a> </li>
57 <li><a href="#2_2">[removed]</a> </li>
58 <li><a href="#2_3">What is this CVS thing that you keep
60 <li><a href="#2_4">How do I know if it works?</a> </li>
61 <li><a href="#2_5">This library is HUGE! And what's libsupc++?</a> </li>
65 <li><a href="#3_0">Platform-Specific Issues</a>
67 <li><a href="#3_1">Can libstdc++-v3 be used with <my
68 favorite compiler>?</a> </li>
69 <li><a href="#3_2">[removed]</a> </li>
70 <li><a href="#3_3">[removed]</a> </li>
71 <li><a href="#3_4">I can't use 'long long' on Solaris</a> </li>
72 <li><a href="#3_5"><code>_XOPEN_SOURCE</code> /
73 <code>_GNU_SOURCE</code> / etc is always defined</a>
75 <li><a href="#3_6">OS X ctype.h is broken! How can I hack it?</a></li>
76 <li><a href="#3_7">Threading is broken on i386</a></li>
77 <li><a href="#3_8">Recent GNU/Linux glibc required?</a></li>
78 <li><a href="#3_9">Can't use wchar_t/wstring on FreeBSD</a></li>
82 <li><a href="#4_0">Known Bugs and Non-Bugs</a>
84 <li><a href="#4_1">What works already?</a> </li>
85 <li><a href="#4_2">Bugs in gcc/g++ (not libstdc++-v3)</a> </li>
86 <li><a href="#4_3">Bugs in the C++ language/lib specification</a> </li>
87 <li><a href="#4_4">Things in libstdc++ that only look like bugs</a><ul>
88 <li><a href="#4_4_iostreamclear">reopening a stream fails</a> </li>
89 <li><a href="#4_4_Weff">-Weffc++ complains too much</a> </li>
90 <li><a href="#4_4_rel_ops">"ambiguous overloads"
91 after including an old-style header</a> </li>
92 <li><a href="#4_4_interface">The g++-3 headers are
93 <strong>not ours</strong></a> </li>
94 <li><a href="#4_4_glibc">compilation errors from streambuf.h</a> </li>
95 <li><a href="#4_4_checks">errors about <em>*Concept</em> and
96 <em>constraints</em> in the STL...</a> </li>
97 <li><a href="#4_4_dlsym">program crashes when using library code
98 in a dynamically-loaded library</a> </li>
99 <li><a href="#4_4_leak">"memory leaks" in containers</a> </li>
102 <li><a href="#4_5">Aw, that's easy to fix!</a> </li>
106 <li><a href="#5_0">Miscellaneous</a>
108 <li><a href="#5_1">string::iterator is not char*;
109 vector<T>::iterator is not T*</a> </li>
110 <li><a href="#5_2">What's next after libstdc++-v3?</a> </li>
111 <li><a href="#5_3">What about the STL from SGI?</a> </li>
112 <li><a href="#5_4">Extensions and Backward Compatibility</a> </li>
113 <li><a href="#5_5">[removed]</a> </li>
114 <li><a href="#5_6">Is libstdc++-v3 thread-safe?</a> </li>
115 <li><a href="#5_7">How do I get a copy of the ISO C++ Standard?</a> </li>
116 <li><a href="#5_8">What's an ABI and why is it so messy?</a> </li>
124 <!-- ####################################################### -->
126 <h1><a name="1_0">1.0 General Information</a></h1>
127 <!-- I suspect these will mostly be links to/into existing documents. -->
128 <h2><a name="1_1">1.1 What is libstdc++-v3?</a></h2>
129 <p>The GNU Standard C++ Library v3 is an
130 ongoing project to implement the ISO 14882 Standard C++ library
131 as described in chapters 17 through 27 and annex D. As the
132 library reaches stable plateaus, it is captured in a snapshot
133 and released. The latest release is
134 <a href="http://gcc.gnu.org/libstdc++/index.html#download">the
135 fourteenth snapshot</a> but newer versions have been included
136 in recent GCC releases. For those who want to see exactly how
137 far the project has come, or just want the latest
138 bleeding-edge code, the up-to-date source is available over
139 anonymous CVS, and can even be browsed over the Web (see
140 <a href="#1_4">1.4</a> below).
142 <p>The older libstdc++-v2 project is no longer maintained; the code
143 has been completely replaced and rewritten.
144 <a href="#4_4_interface">If you are using V2</a>, then you need to
145 report bugs to your system vendor, not to the V3 list.
147 <p>A more formal description of the V3 goals can be found in the
148 official <a href="../17_intro/DESIGN">design document</a>.
152 <h2><a name="1_2">1.2 Why should I use libstdc++?</a></h2>
153 <p>The completion of the ISO C++ standardization gave the
154 C++ community a powerful set of reuseable tools in the form
155 of the C++ Standard Library. However, all existing C++
156 implementations are (as the Draft Standard used to say)
157 "incomplet and incorrekt," and many suffer from
158 limitations of the compilers that use them.
160 <p>The GNU C/C++/FORTRAN/<pick-a-language> compiler
161 (<code>gcc</code>, <code>g++</code>, etc) is widely considered to be
162 one of the leading compilers in the world. Its development
163 has recently been taken over by the
164 <a href="http://gcc.gnu.org/">GCC team</a>. All of
165 the rapid development and near-legendary
166 <a href="http://gcc.gnu.org/gcc-3.0/buildstat.html">portability</a>
167 that are the hallmarks of an open-source project are being
168 applied to libstdc++.
170 <p>That means that all of the Standard classes and functions
171 (such as <code>string</code>, <code>vector<></code>, iostreams,
172 and algorithms) will be freely available and fully compliant.
173 Programmers will no longer need to "roll their own"
174 nor be worried about platform-specific incompatibilities.
178 <h2><a name="1_3">1.3 Who's in charge of it?</a></h2>
179 <p>The libstdc++ project is contributed to by several developers
180 all over the world, in the same way as GCC or Linux.
181 Benjamin Kosnik, Gabriel Dos Reis, Phil Edwards, Ulrich Drepper,
182 Loren James Rittle, and Paolo Carlini are the lead maintainers of
185 <p>Development and discussion is held on the libstdc++ mailing
186 list. Subscribing to the list, or searching the list
187 archives, is open to everyone. You can read instructions for
188 doing so on the <a href="http://gcc.gnu.org/libstdc++/">homepage</a>.
189 If you have questions, ideas, code, or are just curious, sign up!
193 <h2><a name="1_4">1.4 How do I get libstdc++?</a></h2>
194 <p>The fourteenth (and latest) snapshot of libstdc++-v3 is
195 <a href="http://gcc.gnu.org/libstdc++/index.html#download">available
198 <p>The <a href="http://gcc.gnu.org/libstdc++/">homepage</a>
199 has instructions for retrieving the latest CVS sources, and for
200 browsing the CVS sources over the web.
202 <p>The subset commonly known as the Standard Template Library
203 (chapters 23 through 25, mostly) is adapted from the final release
208 <h2><a name="1_5">1.5 When is libstdc++ going to be finished?</a></h2>
209 <!-- <p>Nathan Myers gave the best of all possible answers in <a
210 href="http://www.deja.com/getdoc.xp?AN=469581698&fmt=text">a
211 Usenet article</a>.</p>
212 which is no longer available, thanks deja...-->
213 <p>Nathan Myers gave the best of all possible answers, responding to a
214 Usenet article asking this question: <em>Sooner, if you help.</em>
218 <h2><a name="1_6">1.6 How do I contribute to the effort?</a></h2>
219 <p>Here is <a href="../17_intro/contribute.html">a
220 page devoted to this topic</a>. Subscribing to the mailing
221 list (see above, or the homepage) is a very good idea if you
222 have something to contribute, or if you have spare time and
223 want to help. Contributions don't have to be in the form of
224 source code; anybody who is willing to help write
225 documentation, for example, or has found a bug in code that
226 we all thought was working, is more than welcome!
230 <h2><a name="1_7">1.7 What happened to libg++? I need that!</a></h2>
231 <p>The most recent libg++ README states that libg++ is no longer
232 being actively maintained. It should not be used for new
233 projects, and is only being kicked along to support older code.
235 <p>The libg++ was designed and created when there was no Standard
236 to provide guidance. Classes like linked lists are now provided
237 for by <code>list<T></code> and do not need to be created by
238 <code>genclass</code>. (For that matter, templates exist now and
239 are well-supported, whereas genclass (mostly) predates them.)
241 <p>There are other classes in libg++ that are not specified in the
242 ISO Standard (e.g., statistical analysis). While there are a
243 lot of really useful things that are used by a lot of people
244 (e.g., statistics :-), the Standards Committee couldn't include
245 everything, and so a lot of those "obvious" classes
248 <p>Since libstdc++ is an implementation of the Standard Library, we
249 have no plans at this time to include non-Standard utilities
250 in the implementation, however handy they are. (The extensions
251 provided in the SGI STL aren't maintained by us and don't get
252 a lot of our attention, because they don't require a lot of our
253 time.) It is entirely plausable that the "useful stuff"
254 from libg++ might be extracted into an updated utilities library,
255 but nobody has stated such a project yet.
257 <!-- The advertisement, so to speak, might have to go. Hmmmmm. -->
258 <p>(The <a href="http://www.boost.org/">Boost</a> site houses free
259 C++ libraries that do varying things, and happened to be started
260 by members of the Standards Committee. Certain "useful
261 stuff" classes will probably migrate there.)
263 <p>For the bold and/or desperate, the
264 <a href="http://gcc.gnu.org/extensions.html">GCC extensions page</a>
265 describes where to find the last libg++ source.
269 <h2><a name="1_8">1.8 What if I have more questions?</a></h2>
270 <p>If you have read the README and RELEASE-NOTES files, and your
271 question remains unanswered, then just ask the mailing list.
272 At present, you do not need to be subscribed to the list to
273 send a message to it. More information is available on the
274 homepage (including how to browse the list archives); to send
275 to the list, use <a href="mailto:libstdc++@gcc.gnu.org">
276 <code>libstdc++@gcc.gnu.org</code></a>.
278 <p>If you have a question that you think should be included here,
279 or if you have a question <em>about</em> a question/answer here,
280 contact <a href="mailto:pme@gcc.gnu.org">Phil Edwards</a>
281 or <a href="mailto:gdr@gcc.gnu.org">Gabriel Dos Reis</a>.
285 <h2><a name="1_9">1.9 What are the license terms for libstdc++-v3?</a></h2>
286 <p>See <a href="../17_intro/license.html">our license description</a>
287 for these and related questions.
291 <h1><a name="2_0">2.0 Installation</a></h1>
292 <h2><a name="2_1">2.1 How do I install libstdc++-v3?</a></h2>
293 <p>Complete instructions are not given here (this is a FAQ, not
294 an installation document), but the tools required are few:
297 <li> A 3.x release of GCC. Note that building GCC is much
298 easier and more automated than building the GCC 2.[78]
299 series was. If you are using GCC 2.95, you can still
300 build earlier snapshots of libstdc++.
302 <li> GNU Make is recommended, but should not be required.
304 <li> The GNU Autotools are needed if you are messing with
305 the configury or makefiles.
308 <p>The file <a href="../documentation.html">documentation.html</a>
309 provides a good overview of the steps necessary to build, install,
310 and use the library. Instructions for configuring the library
311 with new flags such as --enable-threads are there also, as well as
312 patches and instructions for working with GCC 2.95.
314 <p>The top-level install.html and
315 <a href="../17_intro/RELEASE-NOTES">RELEASE-NOTES</a> files contain
316 the exact build and installation instructions. You may wish to
317 browse those files over CVSweb ahead of time to get a feel for
318 what's required. RELEASE-NOTES is located in the
319 ".../docs/17_intro/" directory of the distribution.
323 <h2><a name="2_2">2.2 [removed]</a></h2>
324 <p>This question has become moot and has been removed. The stub
325 is here to preserve numbering (and hence links/bookmarks).
329 <h2><a name="2_3">2.3 What is this CVS thing that you
330 keep mentioning?</a></h2>
331 <p>The <em>Concurrent Versions System</em> is one of several revision
332 control packages. It was selected for GNU projects because it's
333 free (speech), free (beer), and very high quality. The <a
334 href="http://www.gnu.org/software/cvs/cvs.html">CVS entry in
335 the GNU software catalogue</a> has a better description as
337 <a href="http://www.cvshome.org/">link to the makers of CVS</a>.
339 <p>The "anonymous client checkout" feature of CVS is
340 similar to anonymous FTP in that it allows anyone to retrieve
341 the latest libstdc++ sources.
343 <p>After the first of April, American users will have a
344 "/pharmacy" command-line option...
345 <!-- wonder how long that'll live -->
349 <h2><a name="2_4">2.4 How do I know if it works?</a></h2>
350 <p>libstdc++-v3 comes with its own testsuite. You do not need
351 to actually install the library ("<code>make
352 install</code>") to run the testsuite.
354 <p>To run the testsuite on the library after building it, use
355 "make check" while in your build directory. To run
356 the testsuite on the library after building and installing it,
357 use "make check-install" instead.
359 <p>If you find bugs in the testsuite programs themselves, or if you
360 think of a new test program that should be added to the suite,
361 <strong>please</strong> write up your idea and send it to the list!
365 <h2><a name="2_5">2.4 This library is HUGE! And what's libsupc++?</a></h2>
366 <p>Usually the size of libraries on disk isn't noticeable. When a
367 link editor (or simply "linker") pulls things from a
368 static archive library, only the necessary object files are copied
369 into your executable, not the entire library. Unfortunately, even
370 if you only need a single function or variable from an object file,
371 the entire object file is extracted. (There's nothing unique to C++
372 or libstdc++-v3 about this; it's just common behavior, given here
373 for background reasons.)
375 <p>Some of the object files which make up libstdc++.a are rather large.
376 If you create a statically-linked executable with
377 <code> -static</code>, those large object files are suddenly part
378 of your executable. Historically the best way around this was to
379 only place a very few functions (often only a single one) in each
380 source/object file; then extracting a single function is the same
381 as extracting a single .o file. For libstdc++-v3 this is only
382 possible to a certain extent; the object files in question contain
383 template classes and template functions, pre-instantiated, and
384 splitting those up causes severe maintenance headaches.
386 <p>It's not a bug, and it's not really a problem. Nevertheless, some
387 people don't like it, so here are two pseudo-solutions:
389 <p>If the only functions from libstdc++.a which you need are language
390 support functions (those listed in
391 <a href="../18_support/howto.html">clause 18</a> of the standard,
392 e.g., <code>new</code> and <code>delete</code>), then try linking
393 against <code>libsupc++.a</code> (usually specifying
394 <code>-lsupc++</code> when calling g++ for the final link step will
395 do it). This library contains only those support routines, one per
396 object file. But if you are using anything from the rest of the
397 library, such as IOStreams or vectors, then you'll still need
398 pieces from <code>libstdc++.a</code>.
400 <p>The second method is one we hope to incorporate into the library
401 build process. Some platforms can place each function and variable
402 into its own section in a .o file. The GNU linker can then perform
403 garbage collection on unused sections; this reduces the situation
404 to only copying needed functions into the executable, as before,
405 but all happens automatically.
407 <p>Unfortunately the garbage collection in GNU ld is buggy; sections
408 (corresponding to functions and variables) which <em>are</em> used
409 are mistakenly removed, leading to horrible crashes when your
410 executable starts up. For the time being, this feature is not used
411 when building the library.
415 <h1><a name="3_0">3.0 Platform-Specific Issues</a></h1>
416 <h2><a name="3_1">3.1 Can libstdc++-v3 be used with <my
417 favorite compiler>?</a></h2>
418 <p>Probably not. Yet.</p>
419 <p>Because GCC advances so rapidly, development and testing of
420 libstdc++ is being done almost entirely under that compiler.
421 If you are curious about whether other, lesser compilers
422 (*grin*) support libstdc++, you are more than welcome to try.
423 Configuring and building the library (see above) will still
424 require certain tools, however. Also keep in mind that
425 <em>building</em> libstdc++ does not imply that your compiler
426 will be able to <em>use</em> all of the features found in the
427 C++ Standard Library.
429 <p>Since the goal of ISO Standardization is for all C++
430 implementations to be able to share code, the final libstdc++
431 should, in theory, be usable under any ISO-compliant
432 compiler. It will still be targeted and optimized for
437 <h2><a name="3_2">3.2 [removed]</a></h2>
438 <p>This question has become moot and has been removed. The stub
439 is here to preserve numbering (and hence links/bookmarks).
443 <h2><a name="3_3">3.3 [removed]</a></h2>
444 <p>This question has become moot and has been removed. The stub
445 is here to preserve numbering (and hence links/bookmarks).
449 <h2><a name="3_4">3.4 I can't use 'long long' on Solaris</a></h2>
450 <p>By default we try to support the C99 <code>long long</code> type.
451 This requires that certain functions from your C library be present.
453 <p>Up through release 3.0.2 the tests performed were too general, and
454 this feature was disabled when it did not need to be. The most
455 commonly reported platform affected was Solaris.
457 <p>This has been fixed for 3.0.3 and onwards.
461 <h2><a name="3_5">3.5 <code>_XOPEN_SOURCE</code> / <code>_GNU_SOURCE</code>
462 / etc is always defined</a></h2>
463 <p>On Solaris, g++ (but not gcc) always defines the preprocessor
464 macro <code>_XOPEN_SOURCE</code>. On GNU/Linux, the same happens
465 with <code>_GNU_SOURCE</code>. (This is not an exhaustive list;
466 other macros and other platforms are also affected.)
468 <p>These macros are typically used in C library headers, guarding new
469 versions of functions from their older versions. The C++ standard
470 library includes the C standard library, but it requires the C90
471 version, which for backwards-compatability reasons is often not the
472 default for many vendors.
474 <p>More to the point, the C++ standard requires behavior which is only
475 available on certain platforms after certain symbols are defined.
476 Usually the issue involves I/O-related typedefs. In order to
477 ensure correctness, the compiler simply predefines those symbols.
479 <p>Note that it's not enough to #define them only when the library is
480 being built (during installation). Since we don't have an 'export'
481 keyword, much of the library exists as headers, which means that
482 the symbols must also be defined as your programs are parsed and
485 <p>To see which symbols are defined, look for CPLUSPLUS_CPP_SPEC in
486 the gcc config headers for your target (and try changing them to
487 see what happens when building complicated code). You can also run
488 <code>"g++ -E -dM - < /dev/null"</code> to display
489 a list of predefined macros for any particular installation.
491 <p>This has been discussed on the mailing lists
492 <a href="http://gcc.gnu.org/cgi-bin/htsearch?method=and&format=builtin-long&sort=score&words=_XOPEN_SOURCE+Solaris">quite a bit</a>.
494 <p>This method is something of a wart. We'd like to find a cleaner
495 solution, but nobody yet has contributed the time.
499 <h2><a name="3_6">3.6 OS X ctype.h is broken! How can I hack it?</a></h2>
500 <p>This is a long-standing bug in the OS X support. Fortunately,
501 the patch is quite simple, and well-known.
502 <a href="http://gcc.gnu.org/ml/gcc/2002-03/msg00817.html"> Here's a
503 link to the solution.</a>
507 <h2><a name="3_7">3.7 Threading is broken on i386</a></h2>
508 <p>Support for atomic integer operations is/was broken on i386
509 platforms. The assembly code accidentally used opcodes that are
510 only available on the i486 and later. So if you configured GCC
511 to target, for example, i386-linux, but actually used the programs
512 on an i686, then you would encounter no problems. Only when
513 actually running the code on a i386 will the problem appear.
515 <p>This is fixed in 3.2.2.
519 <h2><a name="3_8">3.8 Recent GNU/Linux glibc required?</a></h2>
520 <p>For 3.2.1 (shared library version 5.0.1) and later, the library
521 uses localization and formatting code from the system C library
522 (glibc) version 2.2.5. That version of glibc is over a year old
523 and contains necessary bugfixes. Many GNU/Linux distros make
524 glibc version 2.3.x available now.
526 <p>The guideline is simple: the more recent the C++ library, the
527 more recent the C library. (This is also documented in the main
528 GCC installation instructions.)
532 <h2><a name="3_9">3.9 Can't use wchar_t/wstring on FreeBSD</a></h2>
533 <p>At the moment there are a few problems in FreeBSD's support for
534 wide character functions, and as a result the libstdc++ configury
535 decides that wchar_t support should be disabled. Once the underlying
536 problems are fixed in FreeBSD (soon), the library support will
537 automatically enable itself.
539 <p>You can fix the problems yourself, and learn more about the situation,
541 <a href="http://gcc.gnu.org/ml/libstdc++/2003-02/subjects.html#00286">
542 this short thread</a> ("_GLIBCPP_USE_WCHAR_T undefined in
543 FreeBSD's c++config.h?").
547 <h1><a name="4_0">4.0 Known Bugs and Non-Bugs</a></h1>
548 <em>Note that this section can get rapdily outdated -- such is the
549 nature of an open-source project. For the latest information, join
550 the mailing list or look through recent archives. The RELEASE-
551 NOTES and BUGS files are generally kept up-to-date.</em>
553 <p>For 3.0.1, the most common "bug" is an apparently missing
554 "<code>../</code>" in include/Makefile, resulting in files
555 like gthr.h and gthr-single.h not being found. Please read
556 <a href="http://gcc.gnu.org/install/configure.html">the configuration
557 instructions for GCC</a>,
558 specifically the part about configuring in a separate build directory,
559 and how strongly recommended it is. Building in the source directory
560 is fragile, is rarely tested, and tends to break, as in this case.
561 This was fixed for 3.0.2.
564 <p>For 3.1, the most common "bug" is a parse error when using
565 <code><fstream></code>, ending with a message,
566 "<code>bits/basic_file.h:52: parse error before `{'
567 token</code>." Please read
568 <a href="http://gcc.gnu.org/install/">the installation instructions for
569 GCC</a>, specifically the part about not installing newer versions on
570 top of older versions. If you install 3.1 over a 3.0.x release, then
571 the wrong basic_file.h header will be found (its location changed
575 <p><strong>Please do not report these as bugs. We know about them.</strong>
576 Reporting this -- or any other problem that's already been fixed --
577 hinders the development of GCC, because we have to take time to
578 respond to your report. Thank you.
581 <h2><a name="4_1">4.1 What works already?</a></h2>
582 <p>This is a verbatim clip from the "Status" section
583 of the RELEASE-NOTES for the latest snapshot. For a list of
584 fixed bugs, see that file.
587 <!-- Yeah, I meant that "verbatim clip" thing literally... :-) -->
593 - more doxygen documentation
594 - more named locale fixups
595 - stdio_filebuf that takes fd, FILE
596 - io performance tuning
597 - allocation tuning, valgrind fixups
598 - __cxa_demangle now supported
600 - more doxygen documentation.
601 - more named locale bug fixes
602 - support for symbol versioning when using GNU ld >= 2.12
604 - tuning for executable size
606 - more doxygen documentation.
607 - extensions moved out of namespace std
608 - HPUX long long support
609 - more string optimizations
610 - support for NetBSD cross compiles
611 - concept_check merge from boost
612 - header simplification
613 - named locale bug shakeout
616 - add S390, m68k, x86-64 support.
617 - doxygen documentation has been extended, including man pages.
618 - verbose terminate handling has been added.
619 - some libsupc++ tweaks
620 - warnings for deprecated headers now active.
621 - dejagnu testsuite preliminary documentation.
622 - dejagnu testsuite default.
623 - dejagnu testsuite cross compiler, multilib safe.
624 - long long iostreams on by default, rework of ISO C99 support.
625 - iterator re-write and testsuites.
626 - container testsuites.
627 - allocator revamp and testsuites.
628 - more concept-checking work.
629 - basic_string optimization and MT fixes.
630 - new limits implementation.
631 - update -fno-exceptions code, verify it works.
632 - full named locale support fpr all facets, choice of gnu,
633 ieee_1003.1-200x (POSIX 2), or generic models. Full support depends
634 on target OS and underlying "C" library support.
639 <h2><a name="4_2">4.2 Bugs in gcc/g++ (not libstdc++-v3)</a></h2>
640 <p>This is by no means meant to be complete nor exhaustive, but
641 mentions some problems that users may encounter when building
642 or using libstdc++. If you are experiencing one of these
643 problems, you can find more information on the libstdc++ and
644 the GCC mailing lists.
646 <p>Before reporting a bug, examine the
647 <a href="http://gcc.gnu.org/bugs.html">bugs database</a> with the
648 category set to "libstdc++". The BUGS file in the source
649 tree also tracks known serious problems.
652 <li>Debugging is problematic, due to bugs in line-number generation
653 (mostly fixed in the compiler) and gdb lagging behind the
654 compiler (lack of personnel). We recommend configuring the
655 compiler using <code>--with-dwarf2</code> if the DWARF2
656 debugging format is not already the default on your platform.
658 <a href="http://gcc.gnu.org/ml/libstdc++/2002-02/msg00034.html">changing your
659 GDB settings</a> can have a profound effect on your C++ debugging
660 experiences. :-)</li>
664 <h2><a name="4_3">4.3 Bugs in the C++ language/lib specification</a></h2>
665 <p>Yes, unfortunately, there are some. In a
666 <a href="http://gcc.gnu.org/ml/libstdc++/1998/msg00006.html">message
667 to the list</a>, Nathan Myers announced that he has started a list of
668 problems in the ISO C++ Standard itself, especially with
669 regard to the chapters that concern the library. The list
671 <a href="http://www.cantrip.org/draft-bugs.txt">posted on his
672 website</a>. Developers who are having problems interpreting
673 the Standard may wish to consult his notes.
675 <p>For those people who are not part of the ISO Library Group
676 (i.e., nearly all of us needing to read this page in the first
677 place :-), a public list of the library defects is occasionally
678 published <a href="http://anubis.dkuug.dk/jtc1/sc22/wg21/">here</a>.
679 Some of these have resulted in <a href="#5_2">code changes</a>.
683 <h2><a name="4_4">4.4 Things in libstdc++ that only look like bugs</a></h2>
684 <p>There are things which are not bugs in the compiler (4.2) nor
685 the language specification (4.3), but aren't really bugs in
686 libstdc++, either. Really! Please do not report these as bugs.
688 <p><a name="4_4_Weff"><strong>-Weffc++</strong></a>
689 The biggest of these is the quadzillions of warnings about the
690 library headers emitted when <code>-Weffc++</code> is used. Making
691 libstdc++ "-Weffc++-clean" is not a goal of the project,
692 for a few reasons. Mainly, that option tries to enforce
693 object-oriented programming, while the Standard Library isn't
694 necessarily trying to be OO.
696 <p><a name="4_4_iostreamclear"><strong>reopening a stream fails</strong>
697 </a> Did I just say that -Weffc++ was our biggest false-bug report?
698 I lied. (It used to be.) Today it seems to be reports that after
699 executing a sequence like
702 #include <fstream>
704 std::fstream fs("a_file");
706 // . do things with fs...
709 fs.open("a_new_file");</pre>
710 <p>all operations on the re-opened <code>fs</code> will fail, or at
711 least act very strangely. Yes, they often will, especially if
712 <code>fs</code> reached the EOF state on the previous file. The
713 reason is that the state flags are <strong>not</strong> cleared
714 on a successful call to open(). The standard unfortunately did
715 not specify behavior in this case, and to everybody's great sorrow,
716 the <a href="../ext/howto.html#5">proposed LWG resolution</a> (see
717 DR #22) is to leave the flags unchanged. You must insert a call
718 to <code>fs.clear()</code> between the calls to close() and open(),
719 and then everything will work like we all expect it to work.
721 <p><a name="4_4_rel_ops"><strong>rel_ops</strong></a>
722 Another is the <code>rel_ops</code> namespace and the template
723 comparison operator functions contained therein. If they become
724 visible in the same namespace as other comparison functions
725 (e.g., '<code>using</code>' them and the <iterator> header),
726 then you will suddenly be faced with huge numbers of ambiguity
727 errors. This was discussed on the -v3 list; Nathan Myers
728 <a href="http://gcc.gnu.org/ml/libstdc++/2001-01/msg00247.html">sums
729 things up here</a>. The collisions with vector/string iterator
730 types have been fixed for 3.1. <!-- more links to email here -->
732 <h3><a name="4_4_interface">The g++-3 headers are <em>not ours</em></a></h3>
733 <p>If you have found an extremely broken header file which is
734 causing problems for you, look carefully before submitting a
735 "high" priority bug report (which you probably shouldn't
736 do anyhow; see the last paragraph of the page describing
737 <a href="http://gcc.gnu.org/gnatswrite.html">the GCC bug database</a>).
739 <p>If the headers are in <code>${prefix}/include/g++-3</code>, or if
740 the installed library's name looks like <code>libstdc++-2.10.a</code>
741 or <code>libstdc++-libc6-2.10.so</code>,
742 then you are using the old libstdc++-v2 library, which is nonstandard
743 and unmaintained. Do not report problems with -v2 to the -v3
746 <p>For GCC versions 3.0 and 3.1 the libstdc++-v3 header files are
747 installed in <code>${prefix}/include/g++-v3</code> (see the 'v'?).
748 Starting with version 3.2 the headers are installed in
749 <code>${prefix}/include/c++/${version}</code> as this prevents
750 headers from previous versions being found by mistake.
752 <p><a name="4_4_glibc"><strong>glibc</strong></a>
753 If you're on a GNU/Linux system and have just upgraded to
754 glibc 2.2, but are still using gcc 2.95.2, then you should have
755 read the glibc FAQ, specifically 2.34:
758 2.34. When compiling C++ programs, I get a compilation error in streambuf.h.
760 {BH} You are using g++ 2.95.2? After upgrading to glibc 2.2, you need to
761 apply a patch to the include files in /usr/include/g++, because the fpos_t
762 type has changed in glibc 2.2. The patch is at
763 http://clisp.cons.org/~haible/gccinclude-glibc-2.2-compat.diff
765 <p>Note that 2.95.x shipped with the
766 <a href="#4_4_interface">old v2 library</a> which is no longer
767 maintained. Also note that gcc 2.95.3 fixes this problem, but
768 requires a separate patch for libstdc++-v3.
770 <p><a name="4_4_checks"><strong>concept checks</strong></a>
771 If you see compilation errors containing messages about
772 <code> <em>foo</em>Concept </code>and a<code> constraints </code>
773 member function, then most likely you have violated one of the
774 requirements for types used during instantiation of template
775 containers and functions. For example, EqualityComparableConcept
776 appears if your types must be comparable with == and you have not
777 provided this capability (a typo, or wrong visibility, or you
778 just plain forgot, etc).
780 <p>More information, including how to optionally enable/disable the
782 <a href="../19_diagnostics/howto.html#3">here</a>.
784 <p><a name="4_4_dlsym"><strong>dlopen/dlsym</strong></a>
785 If you are using the C++ library across dynamically-loaded
786 objects, make certain that you are passing the correct options
787 when compiling and linking:
790 // compile the library components
796 // create the library
797 g++ -fPIC -shared -rdynamic -o libfoo.so a.o b.o ... z.o
799 // link the executable
800 g++ -fPIC -rdynamic -o foo ... -L. -lfoo -ldl</pre>
801 <p><a name="4_4_leak"><strong>"memory leaks" in containers</strong></a>
802 A few people have reported that the standard containers appear
803 to leak memory when tested with memory checkers such as
804 <a href="http://developer.kde.org/~sewardj/">valgrind</a>.
805 The library's default allocators keep free memory in a pool
806 for later reuse, rather than returning it to the OS. Although
807 this memory is always reachable by the library and is never
808 lost, memory debugging tools can report it as a leak. If you
809 want to test the library for memory leaks please read
810 <a href="../debug.html#mem">Tips for memory leak hunting</a>
815 <h2><a name="4_5">4.5 Aw, that's easy to fix!</a></h2>
816 <p>If you have found a bug in the library and you think you have
817 a working fix, then send it in! The main GCC site has a page
818 on <a href="http://gcc.gnu.org/contribute.html">submitting
819 patches</a> that covers the procedure, but for libstdc++ you
820 should also send the patch to our mailing list in addition to
821 the GCC patches mailing list. The libstdc++
822 <a href="../17_intro/contribute.html">contributors' page</a>
823 also talks about how to submit patches.
825 <p>In addition to the description, the patch, and the ChangeLog
826 entry, it is a Good Thing if you can additionally create a small
827 test program to test for the presence of the bug that your
828 patch fixes. Bugs have a way of being reintroduced; if an old
829 bug creeps back in, it will be caught immediately by the
830 <a href="#2_4">testsuite</a> -- but only if such a test exists.
834 <h1><a name="5_0">5.0 Miscellaneous</a></h1>
835 <h2><a name="5_1">5.1 string::iterator is not char*;
836 vector<T>::iterator is not T*</a></h2>
837 <p>If you have code that depends on container<T> iterators
838 being implemented as pointer-to-T, your code is broken.
840 <p>While there are arguments for iterators to be implemented in
841 that manner, A) they aren't very good ones in the long term,
842 and B) they were never guaranteed by the Standard anyway. The
843 type-safety achieved by making iterators a real class rather
844 than a typedef for <code>T*</code> outweighs nearly all opposing
847 <p>Code which does assume that a vector iterator <code> i </code>
848 is a pointer can often be fixed by changing <code> i </code> in
849 certain expressions to <code> &*i </code>. Future revisions
850 of the Standard are expected to bless this usage for
851 vector<> (but not for basic_string<>).
855 <h2><a name="5_2">5.2 What's next after libstdc++-v3?</a></h2>
856 <p>Hopefully, not much. The goal of libstdc++-v3 is to produce
857 a fully-compliant, fully-portable Standard Library. After that,
858 we're mostly done: there won't <em>be</em> any more compliance
862 <li><p>The ISO Committee will meet periodically to review Defect Reports
863 in the C++ Standard. Undoubtedly some of these will result in
864 changes to the Standard, which will be reflected in patches to
865 libstdc++. Some of that is already happening, see 4.2. Some of
866 those changes are being predicted by the library maintainers, and
867 we add code to the library based on what the current proposed
868 resolution specifies. Those additions are listed in
869 <a href="../ext/howto.html#5">the extensions page</a>.
871 <li><p>Performance tuning. Lots of performance tuning. This too is
872 already underway for post-3.0 releases, starting with memory
873 expansion in container classes and buffer usage in synchronized
876 <li><p>An ABI for libstdc++ is being developed, so that
877 multiple binary-incompatible copies of the library can be replaced
878 with a single backwards-compatible library, like libgcc_s.so is.
880 <li><p>The current libstdc++ contains extensions to the Library which
881 must be explicitly requested by client code (for example, the
882 hash tables from SGI). Other extensions may be added to
883 libstdc++-v3 if they seem to be "standard" enough.
884 (For example, the "long long" type from C99.)
885 Bugfixes and rewrites (to improve or fix thread safety, for
886 instance) will of course be a continuing task.
889 <p><a href="http://gcc.gnu.org/ml/libstdc++/1999/msg00080.html">This
890 question</a> about the next libstdc++ prompted some brief but
892 <a href="http://gcc.gnu.org/ml/libstdc++/1999/msg00084.html">speculation</a>.
896 <h2><a name="5_3">5.3 What about the STL from SGI?</a></h2>
897 <p>The <a href="http://www.sgi.com/Technology/STL/">STL from SGI</a>,
898 version 3.3, was the most recent merge of the STL codebase. The
899 code in libstdc++ contains many fixes and changes, and it is
900 very likely that the SGI code is no longer under active
901 development. We expect that no future merges will take place.
903 <p>In particular, <code>string</code> is not from SGI and makes no
904 use of their "rope" class (which is included as an
905 optional extension), nor is <code>valarray</code> and some others.
906 Classes like <code>vector<></code> are, however.
908 <p>The FAQ for SGI's STL (one jump off of their main page) is
913 <h2><a name="5_4">5.4 Extensions and Backward Compatibility</a></h2>
914 <p>Headers in the <code>ext</code> and <code>backward</code>
915 subdirectories should be referred to by their relative paths:
916 <!-- Careful, the leading spaces in PRE show up directly. -->
919 #include <ext/hash_map> </pre>
920 <p>rather than using <code>-I</code> or other options. This is more
921 portable and forward-compatible. (The situation is the same as
922 that of other headers whose directories are not searched directly,
923 e.g., <code><sys/stat.h></code>, <code><X11/Xlib.h></code>.
926 <p>The extensions are no longer in the global or <code>std</code>
927 namespaces, instead they are declared in the <code>__gnu_cxx</code>
928 namespace. For maximum portability, consider defining a namespace
929 alias to use to talk about extensions, e.g.:
934 #include <hash_map.h>
935 namespace Sgi { using ::hash_map; }; // inherit globals
937 #include <ext/hash_map>
938 #if __GNUC_MINOR__ == 0
939 namespace Sgi = std; // GCC 3.0
941 namespace Sgi = ::__gnu_cxx; // GCC 3.1 and later
944 #else // ... there are other compilers, right?
948 Sgi::hash_map<int,int> my_map; </pre>
949 <p>This is a bit cleaner than defining typedefs for all the
950 instantiations you might need.
953 <p>Extensions to the library have
954 <a href="../ext/howto.html">their own page</a>.
958 <h2><a name="5_5">5.5 [removed]</a></h2>
959 <p>This question has become moot and has been removed. The stub
960 is here to preserve numbering (and hence links/bookmarks).
964 <h2><a name="5_6">5.6 Is libstdc++-v3 thread-safe?</a></h2>
965 <p>When the system's libc is itself thread-safe, a non-generic
966 implementation of atomicity.h exists for the architecture, and gcc
967 itself reports a thread model other than single; libstdc++-v3
968 strives to be thread-safe. The user-code must guard against
969 concurrent method calls which may access any particular library
970 object's state. Typically, the application programmer may infer
971 what object locks must be held based on the objects referenced in
972 a method call. Without getting into great detail, here is an
973 example which requires user-level locks:
976 library_class_a shared_object_a;
979 library_class_b *object_b = new library_class_b;
980 shared_object_a.add_b (object_b); // must hold lock for shared_object_a
981 shared_object_a.mutate (); // must hold lock for shared_object_a
984 // Multiple copies of thread_main() are started in independent threads.</pre>
985 <p>Under the assumption that object_a and object_b are never exposed to
986 another thread, here is an example that should not require any
991 library_class_a object_a;
992 library_class_b *object_b = new library_class_b;
993 object_a.add_b (object_b);
996 <p>All library objects are safe to use in a multithreaded program as
997 long as each thread carefully locks out access by any other thread
998 while it uses any object visible to another thread. In general,
999 this requirement includes both read and write access to objects;
1000 unless otherwise documented as safe, do not assume that two
1001 threads may access a shared standard library object at the
1004 <p>See chapters <a href="../17_intro/howto.html#3">17</a> (library
1005 introduction), <a href="../23_containers/howto.html#3">23</a>
1006 (containers), and <a href="../27_io/howto.html#9">27</a> (I/O) for
1011 <h2><a name="5_7">5.7 How do I get a copy of the ISO C++ Standard?</a></h2>
1012 <p>Copies of the full ISO 14882 standard are available on line via the
1013 ISO mirror site for committee members. Non-members, or those who
1014 have not paid for the privilege of sitting on the committee and
1015 sustained their two-meeting commitment for voting rights, may get a
1016 copy of the standard from their respective national standards
1017 organization. In the USA, this national standards organization is
1018 ANSI and their website is right <a href="http://www.ansi.org">here</a>.
1019 (And if you've already registered with them, clicking this link will
1020 take you to directly to the place where you can
1021 <a href="http://webstore.ansi.org/ansidocstore/product.asp?sku=ISO%2FIEC+14882%2D1998">buy
1022 the standard on-line</a>.
1024 <p>Who is your country's member body? Visit the
1025 <a href="http://www.iso.ch/">ISO homepage</a> and find out!
1029 <h2><a name="5_8">5.8 What's an ABI and why is it so messy?</a></h2>
1030 <p>"ABI" stands for "Application Binary Interface."
1031 Conventionally, it refers to a great mass of details about how
1032 arguments are arranged on the call stack and/or in registers, and
1033 how various types are arranged and padded in structs. A single CPU
1034 design may suffer multiple ABIs designed by different development
1035 tool vendors who made different choices, or even by the same vendor
1036 for different target applications or compiler versions. In ideal
1037 circumstances the CPU designer presents one ABI and all the OSes and
1038 compilers use it. In practice every ABI omits details that compiler
1039 implementers (consciously or accidentally) must choose for themselves.
1041 <p>That ABI definition suffices for compilers to generate code so a
1042 program can interact safely with an OS and its lowest-level libraries.
1043 Users usually want an ABI to encompass more detail, allowing libraries
1044 built with different compilers (or different releases of the same
1045 compiler!) to be linked together. For C++, this includes many more
1046 details than for C, and CPU designers (for good reasons elaborated
1047 below) have not stepped up to publish C++ ABIs. The details include
1048 virtual function implementation, struct inheritance layout, name
1049 mangling, and exception handling. Such an ABI has been defined for
1050 GNU C++, and is immediately useful for embedded work relying only on
1051 a "free-standing implementation" that doesn't include (much
1052 of) the standard library. It is a good basis for the work to come.
1054 <p>A useful C++ ABI must also incorporate many details of the standard
1055 library implementation. For a C ABI, the layouts of a few structs
1056 (such as FILE, stat, jmpbuf, and the like) and a few macros suffice.
1057 For C++, the details include the complete set of names of functions
1058 and types used, the offsets of class members and virtual functions,
1059 and the actual definitions of all inlines. C++ exposes many more
1060 library details to the caller than C does. It makes defining
1061 a complete ABI a much bigger undertaking, and requires not just
1062 documenting library implementation details, but carefully designing
1063 those details so that future bug fixes and optimizations don't
1064 force breaking the ABI.
1066 <p>There are ways to help isolate library implementation details from the
1067 ABI, but they trade off against speed. Library details used in
1068 inner loops (e.g., getchar) must be exposed and frozen for all
1069 time, but many others may reasonably be kept hidden from user code,
1070 so they may later be changed. Deciding which, and implementing
1071 the decisions, must happen before you can reasonably document a
1072 candidate C++ ABI that encompasses the standard library.
1075 <!-- ####################################################### -->
1078 <p class="fineprint"><em>
1079 See <a href="../17_intro/license.html">license.html</a> for copying conditions.
1080 Comments and suggestions are welcome, and may be sent to
1081 <a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>.