source: trunk/third/gcc/BUGS @ 16960

Revision 16960, 23.3 KB checked in by ghudson, 23 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r16959, which included commits to RCS files with non-trunk default branches.
Line 
1
2                                  GCC Bugs
3                                     
4   The latest version of this document is always available at
5   [1]http://www.gnu.org/software/gcc/bugs.html.
6     _________________________________________________________________
7   
8Table of Contents
9
10     * [2]Reporting Bugs
11          + [3]What we need
12          + [4]What we DON'T want
13          + [5]Where to post it
14          + [6]Detailed bug reporting instructions
15     * [7]Managing Bugs (GNATS and the test-suite)
16     * [8]Frequently Reported Bugs in GCC 3.0
17          + [9]General
18          + [10]Fortran
19          + [11]C
20          + [12]C++
21               o [13]Common problems updating from G++ 2.95 to G++ 3.0
22               o [14]Non-bugs
23               o [15]Missing features
24               o [16]Parse errors for "simple" code
25               o [17]Optimization at -O3 takes a very long time
26     _________________________________________________________________
27   
28                                Reporting Bugs
29                                       
30   Our preferred way of receiving bugs is via the [18]GCC GNATS bug
31   reporting system.
32   
33   Before you report a bug, please check the [19]list of well-known bugs
34   and, if possible in any way, try a current development snapshot. If
35   you want to report a bug with versions of GCC before 3.0 we strongly
36   recommend upgrading to the current release first.
37   
38   Before reporting that GCC compiles your code incorrectly, please
39   compile it with gcc -Wall and see whether this shows anything wrong
40   with your code that could be the cause instead of a bug in GCC.
41   
42Summarized bug reporting instructions
43
44   After this summary, you'll find detailed bug reporting instructions,
45   that explain how to obtain some of the information requested in this
46   summary.
47   
48  What we need
49 
50   Please include in your bug report all of the following items, the
51   first three of which can be obtained from the output of gcc -v:
52     * the exact version of GCC;
53     * the system type;
54     * the options given when GCC was configured/built;
55     * the complete command line that triggers the bug;
56     * the compiler output (error messages, warnings, etc.); and
57     * the preprocessed file (*.i*) that triggers the bug, generated by
58       adding -save-temps to the complete compilation command (see
59       below).
60       
61  What we do not want
62 
63     * A source file that #includes header files that are left out of the
64       bug report (see above)
65     * That source file and a collection of header files.
66     * An attached archive (tar, zip, shar, whatever) containing all (or
67       some :-) of the above.
68     * A code snippet that won't cause the compiler to produce the exact
69       output mentioned in the bug report (e.g., a snippet with just a
70       few lines around the one that apparently triggers the bug, with
71       some pieces replaced with ellipses or comments for extra
72       obfuscation :-)
73     * The location (URL) of the package that failed to build (we won't
74       download it, anyway, since you've already given us what we need to
75       duplicate the bug, haven't you? :-)
76     * An error that occurs only some of the times a certain file is
77       compiled, such that retrying a sufficient number of times results
78       in a successful compilation; this is a symptom of a hardware
79       problem, not of a compiler bug (sorry)
80     * E-mail messages that complement previous, incomplete bug reports.
81       Post a new, self-contained, full bug report instead, if possible
82       as a follow-up to the original bug report
83     * Assembly files (*.s) produced by the compiler, or any binary
84       files, such as object files, executables or core files
85     * Duplicate bug reports, or reports of bugs already fixed in the
86       development tree, especially those that have already been reported
87       as fixed last week :-)
88     * Bugs in the assembler, the linker or the C library. These are
89       separate projects, with separate mailing lists and different bug
90       reporting procedures
91     * Bugs in releases or snapshots of GCC not issued by the GNU
92       Project. Report them to whoever provided you with the release
93     * Questions about the correctness or the expected behavior of
94       certain constructs that are not GCC extensions. Ask them in forums
95       dedicated to the discussion of the programming language
96       
97  Where to post it
98 
99   Please submit your bug report directly to the [20]GCC GNATS bug
100   database. Only if this is not possible, mail all information to
101   [21]bug-gcc@gnu.org or [22]gcc-bugs@gcc.gnu.org.
102   
103Detailed bug reporting instructions
104
105   In general, all the information we need can be obtained by collecting
106   the command line below, as well as its output and the preprocessed
107   file it generates.
108   
109     gcc -v -save-temps all-your-options source-file
110     
111   Typically the preprocessed file (extension .i for C or .ii for C++)
112   will be large, so please compress the resulting file with one of the
113   popular compression programs such as bzip2, gzip, zip or compress (in
114   decreasing order of preference). Use maximum compression (-9) if
115   available. Please include the compressed preprocessor output in your
116   bug report, even if the source code is freely available elsewhere; it
117   makes the job of our volunteer testers much easier.
118   
119   The only excuses to not send us the preprocessed sources are (i) if
120   you've found a bug in the preprocessor, or (ii) if you've reduced the
121   testcase to a small file that doesn't include any other file. If you
122   can't post the preprocessed sources because they're proprietary code,
123   then try to create a small file that triggers the same problem.
124   
125   Since we're supposed to be able to re-create the assembly output
126   (extension .s), you usually should not include it in the bug report,
127   although you may want to post parts of it to point out assembly code
128   you consider to be wrong.
129   
130   Whether to use MIME attachments or uuencode is up to you. In any case,
131   make sure the compiler command line, version and error output are in
132   plain text, so that we don't have to decode the bug report in order to
133   tell who should take care of it. A meaningful subject indicating
134   language and platform also helps.
135   
136   Please avoid posting an archive (.tar, .shar or .zip); we generally
137   need just a single file to reproduce the bug (the .i/.ii preprocessed
138   file), and, by storing it in an archive, you're just making our
139   volunteers' jobs harder. Only when your bug report requires multiple
140   source files to be reproduced should you use an archive. In any case,
141   make sure the compiler version, error message, etc, are included in
142   the body of your bug report as plain text, even if needlessly
143   duplicated as part of an archive.
144   
145   The gcc lists have message size limits (200 kbytes) and bug reports
146   over those limits will currently be bounced. If your bug is larger
147   than that, please post it using the [23]GCC GNATS bug database.
148   
149   If you fail to supply enough information for a bug report to be
150   reproduced, someone will probably ask you to post additional
151   information (or just ignore your bug report, if they're in a bad day,
152   so try to get it right on the first posting :-). In this case, please
153   post the additional information to the bug reporting mailing list, not
154   just to the person who requested it, unless explicitly told so. If
155   possible, please include in this follow-up all the information you had
156   supplied in the incomplete bug report (including the preprocessor
157   output), so that the new bug report is self-contained.
158   
159                   Managing Bugs (GNATS and the test-suite)
160                                       
161   This section contains information mostly intended for GCC
162   contributors.
163   
164   If you find a bug, but you are not fixing it (yet):
165    1. Create a (minimal) test-case.
166    2. Add the test-case to our test-suite, marking it as XFAIL.
167    3. Add a bug report referencing the test-case to GNATS.
168       
169   If you fix a bug for which there is already a GNATS entry:
170    1. Remove the XFAIL on the test-case.
171    2. Close the bug report in GNATS.
172       
173   If you find a bug, and you are fixing it right then:
174    1. Create a (minimal) test-case.
175    2. Add the test-case to our test-suite, marking it as PASS.
176    3. Check in your fixes.
177     _________________________________________________________________
178   
179                      Frequently Reported Bugs in GCC 3.0
180                                       
181General
182
183   The following bugs are very frequently reported.
184     * GCC 2.95.2 does not build on GNU/Linux systems using glibc 2.2,
185       such as Red Hat 7.0. This is fixed in GCC 2.95.3 and GCC 3.0.
186     * GCC 2.95.2 crashes when compiling mbx.c from the PINE 4.30 or
187       IMAP2000 distribution on Sparc systems running Solaris.
188     _________________________________________________________________
189   
190Fortran
191
192   Fortran bugs are documented in the G77 manual rather than explicitly
193   listed here. Please see [24]Known Causes of Trouble with GNU Fortran
194   in the G77 manual.
195     _________________________________________________________________
196   
197C
198
199   The following are not bugs in the C compiler, but are reported often
200   enough to warrant a mention here.
201   
202   Cannot initialize a static variable with stdin.
203          This has nothing to do with GCC, but people ask us about it a
204          lot. Code like this:
205         
206     #include <stdio.h> FILE *yyin = stdin;
207     
208          will not compile with GNU libc (GNU/Linux libc6), because stdin
209          is not a constant. This was done deliberately, to make it
210          easier to maintain binary compatibility when the type FILE
211          needs to be changed. It is surprising for people used to
212          traditional Unix C libraries, but it is permitted by the C
213          standard.
214         
215          This construct commonly occurs in code generated by old
216          versions of lex or yacc. We suggest you try regenerating the
217          parser with a current version of flex or bison, respectively.
218          In your own code, the appropriate fix is to move the
219          initialization to the beginning of main.
220         
221          There is a common misconception that the GCC developers are
222          responsible for GNU libc. These are in fact two entirely
223          separate projects; please check the [25]GNU libc web pages for
224          details.
225         
226   Cannot use preprocessor directive in macro arguments.
227          Let me guess... you wrote code that looks something like this:
228         
229     memcpy(dest, src, #ifdef PLATFORM1 12 #else 24 #endif );
230     
231          and you got a whole pile of error messages:
232         
233     test.c:11: warning: preprocessing directive not recognized within
234     macro arg
235     test.c:11: warning: preprocessing directive not recognized within
236     macro arg
237     test.c:11: warning: preprocessing directive not recognized within
238     macro arg
239     test.c: In function `foo':
240     test.c:6: undefined or invalid # directive
241     test.c:8: undefined or invalid # directive
242     test.c:9: parse error before `24'
243     test.c:10: undefined or invalid # directive
244     test.c:11: parse error before `#'
245     
246          The problem, simply put, is that GCC's preprocessor does not
247          allow you to put #ifdef (or any other directive) inside the
248          arguments of a macro. Your C library's <string.h> happens to
249          define memcpy as a macro - this is perfectly legitimate. The
250          code therefore will not compile.
251         
252          We have two good reasons for not allowing directives inside
253          macro arguments. First, it is not portable. It is "undefined
254          behavior" according to the C standard; that means different
255          compilers will do different things with it. Some will give you
256          errors. Some will dump core. Some will silently mangle your
257          code - you could get the equivalent of
258         
259        memcpy(dest, src, 1224);
260
261          from the above example. A very few might do what you expected
262          it to. We therefore feel it is most useful for GCC to reject
263          this construct immediately so that it is found and fixed.
264         
265          Second, it is extraordinarily difficult to implement the
266          preprocessor such that it does what you would expect for every
267          possible directive found inside a macro argument. The best
268          example is perhaps
269         
270     #define foo(arg) ... arg ...
271     foo(blah
272     #undef foo
273     blah)
274     
275          which is impossible to implement in portable C without leaking
276          memory. Allowing only a subset of directives would be
277          confusing.
278         
279          It is always possible to rewrite code which uses conditionals
280          inside macros so that it doesn't. You could write the above
281          example
282         
283     #ifdef PLATFORM1
284     memcpy(dest, src, 12);
285     #else
286     memcpy(dest, src, 24);
287     #endif
288     
289          This is a bit more typing, but I personally think it's better
290          style in addition to being more portable.
291         
292          In recent versions of glibc, printf is among the functions
293          which are implemented as macros.
294     _________________________________________________________________
295   
296C++
297
298   This is the list of bugs (and non-bugs) in g++ (aka GNU C++) that are
299   reported very often, but not yet fixed. While it is certainly better
300   to fix bugs instead of documenting them, this document might save
301   people the effort of writing a bug report when the bug is already
302   well-known. [26]How to report bugs tells you how to report a bug.
303   
304   There are many reasons why reported bugs don't get fixed. It might be
305   difficult to fix, or fixing it might break compatibility. Often,
306   reports get a low priority when there is a simple work-around. In
307   particular, bugs caused by invalid C++ code have a simple work-around,
308   fix the code. Now that there is an agreed ISO/ANSI standard for C++,
309   the compiler has a definitive document to adhere to. Earlier versions
310   might have accepted source code that is no longer C++. This means that
311   code which might have `worked' in a previous version, is now rejected.
312   You should update your code to be C++.
313   
314   You should try to use the latest stable release of the GNU C++
315   compiler. This is currently 3.0. Many commonly reported bugs in
316   earlier releases are fixed in that version.
317   
318  Common problems updating from G++ 2.95 to G++ 3.0
319 
320   G++ 3.0 conforms much closer to the ISO C++ standard (available at
321   [27]http://www.ncits.org/cplusplus.htm).
322   
323   We have also implemented some of the core and library defect reports
324   (available at
325   [28]http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_defects.html &
326   [29]http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html
327   respectively).
328     * The ABI has changed. This means that both class layout and name
329       mangling is different. You must recompile all c++ libraries (if
330       you don't you will get link errors).
331     * The standard library is much more conformant, and uses the std::
332       namespace.
333     * std:: is now a real namespace, not an alias for ::.
334     * The standard header files for the c library don't end with .h, but
335       begin with c (i.e. <cstdlib> rather than <stdlib.h>). The .h names
336       are still available, but are deprecated.
337     * <strstream> is deprecated, use <sstream> instead. (The 3.0 BUGS
338       file says <stringstream>, that was an error, stringstream is the
339       class defined in <sstream>.)
340     * streambuf::seekoff & streambuf::seekpos are private, instead use
341       streambuf::pubseekoff & streambuf::pubseekpos respectively.
342     * If std::operator << (std::ostream &, long long) doesn't exist, you
343       need to recompile libstdc++ with --enable-long-long.
344       
345   This means you may get lots of errors about things like strcmp not
346   being found. You've most likely forgotton to tell the compiler to look
347   in the std:: namespace. There are several ways to do this,
348     * Say, std::strcmp at the call. This is the most explicit way of
349       saying what you mean.
350     * Say, using std::strcmp; somewhere before the call. You will need
351       to do this for each function or type you wish to use from the
352       standard library.
353     * Say, using namespace std; somewhere before the call. This is the
354       quick-but-dirty fix. This brings the whole of the std:: namespace
355       into scope. Never do this in a header file, as you will be forcing
356       users of your header file to do the same.
357       
358  Non-bugs
359 
360   Here are some features that have been reported as bugs, but are not.
361   
362   Nested classes can access private types of the containing class.
363          G++ now implements type access control on member types. Defect
364          report 45 clarifies that nested classes are members of the
365          class they are nested in, and so are granted access to private
366          members of that class.
367         
368   Classes in exception specifiers must be complete types.
369          [15.4]/1 tells you that you cannot have an incomplete type, or
370          pointer to incomplete (other than cv void *) in an exception
371          specification.
372         
373   G++ emits two copies of constructors and destructors.
374          In general there are three types of constructors (and
375          destructors).
376         
377         1. The complete object constructor/destructor.
378         2. The base object constructor/destructor.
379         3. The allocating destructor/deallocating destructor.
380           
381          The first two are different, when virtual base classes are
382          involved. In some cases we can do better, and this is logged in
383          GNATS.
384         
385   Exceptions don't work in multithreaded applications.
386          You need to rebuild g++ and libstdc++ with --enable-threads.
387          Remember, c++ exceptions are not like hardware interrupts. You
388          cannot throw an exception in one thread and catch it in
389          another. You cannot throw an exception from a signal handler,
390          and catch it in the main thread.
391         
392   Global destructors are not run in the correct order.
393          Global destructors should be run in the reverse order of their
394          constructors completing. In most cases this is the same as the
395          reverse order of constructors starting, but sometimes it is
396          different, and that is important. You need to compile and link
397          your programs with --use-cxa-atexit. We have not turned this
398          switch on by default, as it requires a cxa aware runtime
399          library (libc, glibc, or equivalent).
400         
401   Problems with floating point computations.
402          In a number of cases, GCC appears to perform floating point
403          computations incorrectly. For example, the program
404         
405     #include <iostream>
406     int main() {
407     double min = 0.0;
408     double max = 0.5;
409     double width = 0.01;
410     std::cout << (int)(((max - min) / width) - 1) << std::endl;
411     }
412     
413          might print 50 on some systems and optimization levels, and 51
414          on others.
415         
416          The is the result of rounding: The computer cannot represent
417          all real numbers exactly, so it has to use approximations. When
418          computing with approximation, the computer needs to round to
419          the nearest representable number.
420         
421          This is not a bug in the compiler, but an inherent limitation
422          of the float and double types. Please study [30]this paper for
423          more information.
424         
425  Missing features
426 
427   We know some things are missing from G++.
428   
429   The export keyword is not implemented.
430          Most C++ compilers (G++ included) do not yet implement export,
431          which is necessary for separate compilation of template
432          declarations and definitions. Without export, a template
433          definition must be in scope to be used. The obvious workaround
434          is simply to place all definitions in the header itself.
435          Alternatively, the compilation unit containing template
436          definitions may be included from the header.
437         
438   Two stage lookup in templates is not implemented.
439          [14.6] specifies how names are looked up inside a template. G++
440          does not do this correctly, but for most templates this will
441          not be noticeable.
442         
443  Parse errors for "simple" code
444 
445   Up to and including GCC 3.0, the compiler will give "parse error" for
446   seemingly simple code, such as
447struct A{
448  A();
449  A(int);
450  void func();
451};
452
453struct B{
454  B(A);
455  B(A,A);
456  void func();
457};
458
459void foo(){
460  B b(A(),A(1));     //Variable b, initialized with two temporaries
461  B(A(2)).func();    //B temporary, initialized with A temporary
462}
463
464   The problem is that GCC starts to parse the declaration of b as a
465   function b returning B, taking a function returning A as an argument.
466   When it sees the 1, it is too late. The work-around in these cases is
467   to add additional parentheses around the expressions that are mistaken
468   as declarations:
469  (B(A(2))).func();
470
471   Sometimes, even that is not enough; to show the compiler that this
472   should be really an expression, a comma operator with a dummy argument
473   can be used:
474  B b((0,A()),A(1));
475
476   Another example is the parse error for the return statement in
477struct A{};
478
479struct B{
480  A a;
481  A f1(bool);
482};
483
484A B::f1(bool b)
485{
486  if (b)
487    return (A());
488  return a;
489}
490
491   The problem is that the compiler interprets A() as a function (taking
492   no arguments, returning A), and (A()) as a cast - with a missing
493   expression, hence the parse error. The work-around is to omit the
494   parentheses:
495  if (b)
496    return A();
497
498   This problem occurs in a number of variants; in throw statements,
499   people also frequently put the object in parentheses. The exact error
500   also somewhat varies with the compiler version. The work-arounds
501   proposed do not change the semantics of the program at all; they make
502   them perhaps less readable.
503   
504  Optimization at -O3 takes a very long time
505 
506   At -O3, all functions are candidates for inlining. The heuristic used
507   has some deficiencies which show up when allowed such freedom. This is
508   g++ specific, as it has an earlier inliner than gcc.
509
510References
511
512   1. http://www.gnu.org/software/gcc/bugs.html
513   2. http://gcc.gnu.org/bugs.html#report
514   3. http://gcc.gnu.org/bugs.html#need
515   4. http://gcc.gnu.org/bugs.html#dontwant
516   5. http://gcc.gnu.org/bugs.html#where
517   6. http://gcc.gnu.org/bugs.html#detailed
518   7. http://gcc.gnu.org/bugs.html#manage
519   8. http://gcc.gnu.org/bugs.html#known
520   9. http://gcc.gnu.org/bugs.html#general
521  10. http://gcc.gnu.org/bugs.html#fortran
522  11. http://gcc.gnu.org/bugs.html#c
523  12. http://gcc.gnu.org/bugs.html#cplusplus
524  13. http://gcc.gnu.org/bugs.html#updating
525  14. http://gcc.gnu.org/bugs.html#nonbugs
526  15. http://gcc.gnu.org/bugs.html#missing
527  16. http://gcc.gnu.org/bugs.html#parsing
528  17. http://gcc.gnu.org/bugs.html#-O3
529  18. http://gcc.gnu.org/gnats.html
530  19. http://gcc.gnu.org/bugs.html#known
531  20. http://gcc.gnu.org/gnats.html
532  21. mailto:bug-gcc@gnu.org
533  22. mailto:gcc-bugs@gcc.gnu.org
534  23. http://gcc.gnu.org/gnats.html
535  24. http://gcc.gnu.org/onlinedocs/g77_bugs.html
536  25. http://www.gnu.org/software/glibc/
537  26. http://gcc.gnu.org/bugs.html#report
538  27. http://www.ncits.org/cplusplus.htm
539  28. http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_defects.html
540  29. http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html
541  30. http://www.validlab.com/goldberg/paper.ps
Note: See TracBrowser for help on using the repository browser.