URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [BUGS] - Rev 816
Compare with Previous | Blame | View Log
GCC BugsThe latest version of this document is always available at[1]http://gcc.gnu.org/bugs.html._________________________________________________________________Table of Contents* [2]Reporting Bugs+ [3]What we need+ [4]What we DON'T want+ [5]Where to post it+ [6]Detailed bug reporting instructions+ [7]Detailed bug reporting instructions for GNAT+ [8]Detailed bug reporting instructions when using a precompiledheader* [9]Frequently Reported Bugs in GCC+ [10]C++o [11]Missing featureso [12]Bugs fixed in the 3.4 series+ [13]Fortran* [14]Non-bugs+ [15]General+ [16]C+ [17]C++o [18]Common problems when upgrading the compiler_________________________________________________________________Reporting BugsThe main purpose of a bug report is to enable us to fix the bug. The mostimportant prerequisite for this is that the report must be complete andself-contained.Before you report a bug, please check the [19]list of well-known bugs and,if possible, try a current development snapshot. If you want to report a bugwith versions of GCC before 3.4 we strongly recommend upgrading to thecurrent release first.Before reporting that GCC compiles your code incorrectly, please compile itwith gcc -Wall and see whether this shows anything wrong with your code thatcould be the cause instead of a bug in GCC.Summarized bug reporting instructionsAfter this summary, you'll find detailed bug reporting instructions, thatexplain how to obtain some of the information requested in this summary.What we needPlease include in your bug report all of the following items, the firstthree of which can be obtained from the output of gcc -v:* the exact version of GCC;* the system type;* the options given when GCC was configured/built;* the complete command line that triggers the bug;* the compiler output (error messages, warnings, etc.); and* the preprocessed file (*.i*) that triggers the bug, generated by adding-save-temps to the complete compilation command, or, in the case of abug report for the GNAT front end, a complete set of source files (seebelow).What we do not want* A source file that #includes header files that are left out of the bugreport (see above)* That source file and a collection of header files.* An attached archive (tar, zip, shar, whatever) containing all (or some:-) of the above.* A code snippet that won't cause the compiler to produce the exact outputmentioned in the bug report (e.g., a snippet with just a few linesaround the one that apparently triggers the bug, with some piecesreplaced with ellipses or comments for extra obfuscation :-)* The location (URL) of the package that failed to build (we won'tdownload it, anyway, since you've already given us what we need toduplicate the bug, haven't you? :-)* An error that occurs only some of the times a certain file is compiled,such that retrying a sufficient number of times results in a successfulcompilation; this is a symptom of a hardware problem, not of a compilerbug (sorry)* Assembly files (*.s) produced by the compiler, or any binary files, suchas object files, executables, core files, or precompiled header files* Duplicate bug reports, or reports of bugs already fixed in thedevelopment tree, especially those that have already been reported asfixed last week :-)* Bugs in the assembler, the linker or the C library. These are separateprojects, with separate mailing lists and different bug reportingprocedures* Bugs in releases or snapshots of GCC not issued by the GNU Project.Report them to whoever provided you with the release* Questions about the correctness or the expected behavior of certainconstructs that are not GCC extensions. Ask them in forums dedicated tothe discussion of the programming languageWhere to post itPlease submit your bug report directly to the [20]GCC bug database.Alternatively, you can use the gccbug script that mails your bug report tothe bug database.Only if all this is absolutely impossible, mail all information to[21]gcc-bugs@gcc.gnu.org.Detailed bug reporting instructionsPlease refer to the [22]next section when reporting bugs in GNAT, the Adacompiler, or to the [23]one after that when reporting bugs that appear whenusing a precompiled header.In general, all the information we need can be obtained by collecting thecommand line below, as well as its output and the preprocessed file itgenerates.gcc -v -save-temps all-your-options source-fileThe only excuses to not send us the preprocessed sources are (i) if you'vefound a bug in the preprocessor, (ii) if you've reduced the testcase to asmall file that doesn't include any other file or (iii) if the bug appearsonly when using precompiled headers. If you can't post the preprocessedsources because they're proprietary code, then try to create a small filethat triggers the same problem.Since we're supposed to be able to re-create the assembly output (extension.s), you usually should not include it in the bug report, although you maywant to post parts of it to point out assembly code you consider to bewrong.Please avoid posting an archive (.tar, .shar or .zip); we generally needjust a single file to reproduce the bug (the .i/.ii/.f preprocessed file),and, by storing it in an archive, you're just making our volunteers' jobsharder. Only when your bug report requires multiple source files to bereproduced should you use an archive. This is, for example, the case if youare using INCLUDE directives in Fortran code, which are not processed by thepreprocessor, but the compiler. In that case, we need the main file and allINCLUDEd files. In any case, make sure the compiler version, error message,etc, are included in the body of your bug report as plain text, even ifneedlessly duplicated as part of an archive.Detailed bug reporting instructions for GNATSee the [24]previous section for bug reporting instructions for GCC languageimplementations other than Ada.Bug reports have to contain at least the following information in order tobe useful:* the exact version of GCC, as shown by "gcc -v";* the system type;* the options when GCC was configured/built;* the exact command line passed to the gcc program triggering the bug (notjust the flags passed to gnatmake, but gnatmake prints the parameters itpassed to gcc)* a collection of source files for reproducing the bug, preferably aminimal set (see below);* a description of the expected behavior;* a description of actual behavior.If your code depends on additional source files (usually packagespecifications), submit the source code for these compilation units in asingle file that is acceptable input to gnatchop, i.e. contains no non-Adatext. If the compilation terminated normally, you can usually obtain a listof dependencies using the "gnatls -d main_unit" command, where main_unit isthe file name of the main compilation unit (which is also passed to gcc).If you report a bug which causes the compiler to print a bug box, includethat bug box in your report, and do not forget to send all the source fileslisted after the bug box along with your report.If you use gnatprep, be sure to send in preprocessed sources (unless youhave to report a bug in gnatprep).When you have checked that your report meets these criteria, please submitit according to our [25]generic instructions. (If you use a mailing list forreporting, please include an "[Ada]" tag in the subject.)Detailed bug reporting instructions when using a precompiled headerIf you're encountering a bug when using a precompiled header, the firstthing to do is to delete the precompiled header, and try running the sameGCC command again. If the bug happens again, the bug doesn't really involveprecompiled headers, please report it without using them by following theinstructions [26]above.If you've found a bug while building a precompiled header (for instance, thecompiler crashes), follow the usual instructions [27]above.If you've found a real precompiled header bug, what we'll need to reproduceit is the sources to build the precompiled header (as a single .i file), thesource file that uses the precompiled header, any other headers that sourcefile includes, and the command lines that you used to build the precompiledheader and to use it.Please don't send us the actual precompiled header. It is likely to be verylarge and we can't use it to reproduce the problem._________________________________________________________________Frequently Reported Bugs in GCCThis is a list of bugs in GCC that are reported very often, but not yetfixed. While it is certainly better to fix bugs instead of documenting them,this document might save people the effort of writing a bug report when thebug is already well-known.There are many reasons why a reported bug doesn't get fixed. It might bedifficult to fix, or fixing it might break compatibility. Often, reports geta low priority when there is a simple work-around. In particular, bugscaused by invalid code have a simple work-around: fix the code._________________________________________________________________C++Missing featuresThe export keyword is not implemented.Most C++ compilers (G++ included) do not yet implement export, whichis necessary for separate compilation of template declarations anddefinitions. Without export, a template definition must be in scopeto be used. The obvious workaround is simply to place all definitionsin the header itself. Alternatively, the compilation unit containingtemplate definitions may be included from the header.Bugs fixed in the 3.4 seriesThe following bugs are present up to (and including) GCC 3.3.x. They havebeen fixed in 3.4.0.Two-stage name-lookup.GCC did not implement two-stage name-lookup (also see [28]below).Covariant return types.GCC did not implement non-trivial covariant returns.Parse errors for "simple" code.GCC gave parse errors for seemingly simple code, such asstruct A{A();A(int);};struct B{B(A);B(A,A);void foo();};A bar(){B b(A(),A(1)); // Variable b, initialized with two temporariesB(A(2)).foo(); // B temporary, initialized with A temporaryreturn (A()); // return A temporary}Although being valid code, each of the three lines with a comment wasrejected by GCC. The work-arounds for older compiler versionsproposed below do not change the semantics of the programs at all.The problem in the first case was that GCC started to parse thedeclaration of b as a function called b returning B, taking afunction returning A as an argument. When it encountered the 1, itwas too late. To show the compiler that this should be really anexpression, a comma operator with a dummy argument could be used:B b((0,A()),A(1));The work-around for simpler cases like the second one was to addadditional parentheses around the expressions that were mistaken asdeclarations:(B(A(2))).foo();In the third case, however, additional parentheses were causing theproblems: The compiler interpreted A() as a function (taking noarguments, returning A), and (A()) as a cast lacking an expression tobe casted, hence the parse error. The work-around was to omit theparentheses:return A();This problem occurred in a number of variants; in throw statements,people also frequently put the object in parentheses._________________________________________________________________FortranG77 bugs are documented in the G77 manual rather than explicitly listedhere. Please see [29]Known Causes of Trouble with GNU Fortran in the G77manual._________________________________________________________________Non-bugsThe following are not actually bugs, but are reported often enough towarrant a mention here.It is not always a bug in the compiler, if code which "worked" in a previousversion, is now rejected. Earlier versions of GCC sometimes were less pickyabout standard conformance and accepted invalid source code. In addition,programming languages themselves change, rendering code invalid that used tobe conforming (this holds especially for C++). In either case, you shouldupdate your code to match recent language standards._________________________________________________________________GeneralProblems with floating point numbers - the [30]most often reported non-bug.In a number of cases, GCC appears to perform floating pointcomputations incorrectly. For example, the C++ program#include <iostream>int main(){double a = 0.5;double b = 0.01;std::cout << (int)(a / b) << std::endl;return 0;}might print 50 on some systems and optimization levels, and 49 onothers.This is the result of rounding: The computer cannot represent allreal numbers exactly, so it has to use approximations. When computingwith approximation, the computer needs to round to the nearestrepresentable number.This is not a bug in the compiler, but an inherent limitation of thefloating point types. Please study [31]this paper for moreinformation._________________________________________________________________CIncrement/decrement operator (++/--) not working as expected - a [32]problemwith many variations.The following expressions have unpredictable results:x[i]=++ifoo(i,++i)i*(++i) /* special case with foo=="operator*" */std::cout << i << ++i /* foo(foo(std::cout,i),++i) */since the i without increment can be evaluated before or after ++i.The C and C++ standards have the notion of "sequence points".Everything that happens between two sequence points happens in anunspecified order, but it has to happen after the first and beforethe second sequence point. The end of a statement and a function callare examples for sequence points, whereas assignments and the commabetween function arguments are not.Modifying a value twice between two sequence points as shown in thefollowing examples is even worse:i=++ifoo(++i,++i)(++i)*(++i) /* special case with foo=="operator*" */std::cout << ++i << ++i /* foo(foo(std::cout,++i),++i) */This leads to undefined behavior (i.e. the compiler can do anything).Casting does not work as expected when optimization is turned on.This is often caused by a violation of aliasing rules, which are partof the ISO C standard. These rules say that a program is invalid ifyou try to access a variable through a pointer of an incompatibletype. This is happening in the following example where a short isaccessed through a pointer to integer (the code assumes 16-bit shortsand 32-bit ints):#include <stdio.h>int main(){short a[2];a[0]=0x1111;a[1]=0x1111;*(int *)a = 0x22222222; /* violation of aliasing rules */printf("%x %x\n", a[0], a[1]);return 0;}The aliasing rules were designed to allow compilers more aggressiveoptimization. Basically, a compiler can assume that all changes tovariables happen through pointers or references to variables of atype compatible to the accessed variable. Dereferencing a pointerthat violates the aliasing rules results in undefined behavior.In the case above, the compiler may assume that no access through aninteger pointer can change the array a, consisting of shorts. Thus,printf may be called with the original values of a[0] and a[1]. Whatreally happens is up to the compiler and may change with architectureand optimization level.Recent versions of GCC turn on the option -fstrict-aliasing (whichallows alias-based optimizations) by default with -O2. And somearchitectures then really print "1111 1111" as result. Withoutoptimization the executable will generate the "expected" output "22222222".To disable optimizations based on alias-analysis for faulty legacycode, the option -fno-strict-aliasing can be used as a work-around.The option -Wstrict-aliasing (which is included in -Wall) warns aboutsome - but not all - cases of violation of aliasing rules when-fstrict-aliasing is active.To fix the code above, you can use a union instead of a cast (notethat this is a GCC extension which might not work with othercompilers):#include <stdio.h>int main(){union{short a[2];int i;} u;u.a[0]=0x1111;u.a[1]=0x1111;u.i = 0x22222222;printf("%x %x\n", u.a[0], u.a[1]);return 0;}Now the result will always be "2222 2222".For some more insight into the subject, please have a look at[33]this article.Cannot use preprocessor directive in macro arguments.Let me guess... you used an older version of GCC to compile code thatlooks something like this:memcpy(dest, src,#ifdef PLATFORM112#else24#endif);and you got a whole pile of error messages:test.c:11: warning: preprocessing directive not recognized within macro argtest.c:11: warning: preprocessing directive not recognized within macro argtest.c:11: warning: preprocessing directive not recognized within macro argtest.c: In function `foo':test.c:6: undefined or invalid # directivetest.c:8: undefined or invalid # directivetest.c:9: parse error before `24'test.c:10: undefined or invalid # directiveThis is because your C library's <string.h> happens to define memcpyas a macro - which is perfectly legitimate. In recent versions ofglibc, for example, printf is among those functions which areimplemented as macros.Versions of GCC prior to 3.3 did not allow you to put #ifdef (or anyother preprocessor directive) inside the arguments of a macro. Thecode therefore would not compile.As of GCC 3.3 this kind of construct is always accepted and thepreprocessor will probably do what you expect, but see the manual fordetailed semantics.However, this kind of code is not portable. It is "undefinedbehavior" according to the C standard; that means different compilersmay do different things with it. It is always possible to rewritecode which uses conditionals inside macros so that it doesn't. Youcould write the above example#ifdef PLATFORM1memcpy(dest, src, 12);#elsememcpy(dest, src, 24);#endifThis is a bit more typing, but I personally think it's better stylein addition to being more portable.Cannot initialize a static variable with stdin.This has nothing to do with GCC, but people ask us about it a lot.Code like this:#include <stdio.h>FILE *yyin = stdin;will not compile with GNU libc, because stdin is not a constant. Thiswas done deliberately, to make it easier to maintain binarycompatibility when the type FILE needs to be changed. It issurprising for people used to traditional Unix C libraries, but it ispermitted by the C standard.This construct commonly occurs in code generated by old versions oflex or yacc. We suggest you try regenerating the parser with acurrent version of flex or bison, respectively. In your own code, theappropriate fix is to move the initialization to the beginning ofmain.There is a common misconception that the GCC developers areresponsible for GNU libc. These are in fact two entirely separateprojects; please check the [34]GNU libc web pages for details._________________________________________________________________C++Nested classes can access private members and types of the containing class.Defect report 45 clarifies that nested classes are members of theclass they are nested in, and so are granted access to privatemembers of that class.G++ emits two copies of constructors and destructors.In general there are three types of constructors (and destructors).1. The complete object constructor/destructor.2. The base object constructor/destructor.3. The allocating constructor/deallocating destructor.The first two are different, when virtual base classes are involved.Global destructors are not run in the correct order.Global destructors should be run in the reverse order of theirconstructors completing. In most cases this is the same as thereverse order of constructors starting, but sometimes it isdifferent, and that is important. You need to compile and link yourprograms with --use-cxa-atexit. We have not turned this switch on bydefault, as it requires a cxa aware runtime library (libc, glibc, orequivalent).Classes in exception specifiers must be complete types.[15.4]/1 tells you that you cannot have an incomplete type, orpointer to incomplete (other than cv void *) in an exceptionspecification.Exceptions don't work in multithreaded applications.You need to rebuild g++ and libstdc++ with --enable-threads.Remember, C++ exceptions are not like hardware interrupts. You cannotthrow an exception in one thread and catch it in another. You cannotthrow an exception from a signal handler and catch it in the mainthread.Templates, scoping, and digraphs.If you have a class in the global namespace, say named X, and want togive it as a template argument to some other class, say std::vector,then std::vector<::X> fails with a parser error.The reason is that the standard mandates that the sequence <: istreated as if it were the token [. (There are several suchcombinations of characters - they are called digraphs.) Depending onthe version, the compiler then reports a parse error before thecharacter : (the colon before X) or a missing closing bracket ].The simplest way to avoid this is to write std::vector< ::X>, i.e.place a space between the opening angle bracket and the scopeoperator.Copy constructor access check while initializing a reference.Consider this code:class A{public:A();private:A(const A&); // private copy ctor};A makeA(void);void foo(const A&);void bar(void){foo(A()); // error, copy ctor is not accessiblefoo(makeA()); // error, copy ctor is not accessibleA a1;foo(a1); // OK, a1 is a lvalue}Starting with GCC 3.4.0, binding an rvalue to a const referencerequires an accessible copy constructor. This might be surprising atfirst sight, especially since most popular compilers do not correctlyimplement this rule.The C++ Standard says that a temporary object should be created inthis context and its contents filled with a copy of the object we aretrying to bind to the reference; it also says that the temporary copycan be elided, but the semantic constraints (eg. accessibility) ofthe copy constructor still have to be checked.For further information, you can consult the following paragraphs ofthe C++ standard: [dcl.init.ref]/5, bullet 2, sub-bullet 1, and[class.temporary]/2.Common problems when upgrading the compilerABI changesThe C++ application binary interface (ABI) consists of two components: thefirst defines how the elements of classes are laid out, how functions arecalled, how function names are mangled, etc; the second part deals with theinternals of the objects in libstdc++. Although we strive for a non-changingABI, so far we have had to modify it with each major release. If you changeyour compiler to a different major release you must recompile all librariesthat contain C++ code. If you fail to do so you risk getting linker errorsor malfunctioning programs. Some of our Java support libraries also containC++ code, so you might want to recompile all libraries to be safe. It shouldnot be necessary to recompile if you have changed to a bug-fix release ofthe same version of the compiler; bug-fix releases are careful to avoid ABIchanges. See also the [35]compatibility section of the GCC manual.Remark: A major release is designated by a change to the first or secondcomponent of the two- or three-part version number. A minor (bug-fix)release is designated by a change to the third component only. Thus GCC 3.2and 3.3 are major releases, while 3.3.1 and 3.3.2 are bug-fix releases forGCC 3.3. With the 3.4 series we are introducing a new naming scheme; thefirst release of this series is 3.4.0 instead of just 3.4.Standard conformanceWith each release, we try to make G++ conform closer to the ISO C++ standard(available at [36]http://www.ncits.org/cplusplus.htm). We have alsoimplemented some of the core and library defect reports (available at[37]http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html &[38]http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.htmlrespectively).Non-conforming legacy code that worked with older versions of GCC may berejected by more recent compilers. There is no command-line switch to ensurecompatibility in general, because trying to parse standard-conforming andold-style code at the same time would render the C++ frontendunmaintainable. However, some non-conforming constructs are allowed when thecommand-line option -fpermissive is used.Two milestones in standard conformance are GCC 3.0 (including a majoroverhaul of the standard library) and the 3.4.0 version (with its new C++parser).New in GCC 3.0* The standard library is much more conformant, and uses the std::namespace (which is now a real namespace, not an alias for ::).* The standard header files for the c library don't end with .h, but beginwith c (i.e. <cstdlib> rather than <stdlib.h>). The .h names are stillavailable, but are deprecated.* <strstream> is deprecated, use <sstream> instead.* streambuf::seekoff & streambuf::seekpos are private, instead usestreambuf::pubseekoff & streambuf::pubseekpos respectively.* If std::operator << (std::ostream &, long long) doesn't exist, you needto recompile libstdc++ with --enable-long-long.If you get lots of errors about things like cout not being found, you'vemost likely forgotten to tell the compiler to look in the std:: namespace.There are several ways to do this:* Say std::cout at the call. This is the most explicit way of saying whatyou mean.* Say using std::cout; somewhere before the call. You will need to do thisfor each function or type you wish to use from the standard library.* Say using namespace std; somewhere before the call. This is thequick-but-dirty fix. This brings the whole of the std:: namespace intoscope. Never do this in a header file, as every user of your header filewill be affected by this decision.New in GCC 3.4.0The new parser brings a lot of improvements, especially concerningname-lookup.* The "implicit typename" extension got removed (it was already deprecatedsince GCC 3.1), so that the following code is now rejected, see [14.6]:template <typename> struct A{typedef int X;};template <typename T> struct B{A<T>::X x; // errortypename A<T>::X y; // OK};B<void> b;* For similar reasons, the following code now requires the templatekeyword, see [14.2]:template <typename> struct A{template <int> struct X {};};template <typename T> struct B{typename A<T>::X<0> x; // errortypename A<T>::template X<0> y; // OK};B<void> b;* We now have two-stage name-lookup, so that the following code isrejected, see [14.6]/9:template <typename T> int foo(){return i; // error}* This also affects members of base classes, see [14.6.2]:template <typename> struct A{int i, j;};template <typename T> struct B : A<T>{int foo1() { return i; } // errorint foo2() { return this->i; } // OKint foo3() { return B<T>::i; } // OKint foo4() { return A<T>::i; } // OKusing A<T>::j;int foo5() { return j; } // OK};In addition to the problems listed above, the manual contains a section on[39]Common Misunderstandings with GNU C++.References1. http://gcc.gnu.org/bugs.html2. http://gcc.gnu.org/bugs.html#report3. http://gcc.gnu.org/bugs.html#need4. http://gcc.gnu.org/bugs.html#dontwant5. http://gcc.gnu.org/bugs.html#where6. http://gcc.gnu.org/bugs.html#detailed7. http://gcc.gnu.org/bugs.html#gnat8. http://gcc.gnu.org/bugs.html#pch9. http://gcc.gnu.org/bugs.html#known10. http://gcc.gnu.org/bugs.html#cxx11. http://gcc.gnu.org/bugs.html#missing12. http://gcc.gnu.org/bugs.html#fixed3413. http://gcc.gnu.org/bugs.html#fortran14. http://gcc.gnu.org/bugs.html#nonbugs15. http://gcc.gnu.org/bugs.html#nonbugs_general16. http://gcc.gnu.org/bugs.html#nonbugs_c17. http://gcc.gnu.org/bugs.html#nonbugs_cxx18. http://gcc.gnu.org/bugs.html#upgrading19. http://gcc.gnu.org/bugs.html#known20. http://gcc.gnu.org/bugzilla/21. mailto:gcc-bugs@gcc.gnu.org22. http://gcc.gnu.org/bugs.html#gnat23. http://gcc.gnu.org/bugs.html#pch24. http://gcc.gnu.org/bugs.html#detailed25. http://gcc.gnu.org/bugs.html#where26. http://gcc.gnu.org/bugs.html#detailed27. http://gcc.gnu.org/bugs.html#detailed28. http://gcc.gnu.org/bugs.html#new3429. http://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/Trouble.html30. http://gcc.gnu.org/PR32331. http://www.validlab.com/goldberg/paper.ps32. http://gcc.gnu.org/PR1175133. http://mail-index.NetBSD.org/tech-kern/2003/08/11/0001.html34. http://www.gnu.org/software/libc/35. http://gcc.gnu.org/onlinedocs/gcc/Compatibility.html36. http://www.ncits.org/cplusplus.htm37. http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html38. http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html39. http://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Misunderstandings.html
