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