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