The latest version of this document is always available at http://gcc.gnu.org/bugs.html.

Reporting Bugs | Managing Bugs (GNATS and the test-suite) | Frequently Reported Bugs in GCC 3.0

Reporting Bugs

Our preferred way of receiving bugs is via our GNATS bug reporting system.

Before you report a bug, please check the list of well-known bugs and, if possible in any way, try a current development snapshot or CodeSourcery's Online Test Compilation. If you want to report a bug with egcs 1.x or versions of GCC before 3.0 we strongly recommend upgrading to the current release first.

Before reporting that GCC compiles your code incorrectly, please compile it with gcc -Wall and see whether this shows anything wrong with your code that could be the cause instead of a bug in GCC.

Summarized bug reporting instructions

After this summary, you'll find detailed bug reporting instructions, that explain how to obtain some of the information requested in this summary.

What we need

Please include in your bug report all of the following items:

What we DON'T want

Where to post it

Please submit your bug report directly to our GNATS bug database. If this is not possible, please mail all information to gcc-bugs@gcc.gnu.org.

Detailed bug reporting instructions

In general, all the information we need can be obtained by collecting the command line below, as well as its output and the preprocessed file it generates.

gcc -v -save-temps all-your-options source-file

Typically the preprocessed file (extension .i for C or .ii for C++) will be large, so please compress the resulting file with one of the popular compression programs such as bzip2, gzip, zip or compress (in decreasing order of preference). Use maximum compression (-9) if available. Please include the compressed preprocessor output in your bug report, even if the source code is freely available elsewhere; it makes the job of our volunteer testers much easier.

The only excuses to not send us the preprocessed sources are (i) if you've found a bug in the preprocessor, or (ii) if you've reduced the testcase to a small file that doesn't include any other file. If you can't post the preprocessed sources because they're proprietary code, then try to create a small file that 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 may want to post parts of it to point out assembly code you consider to be wrong.

Whether to use MIME attachments or uuencode is up to you. In any case, make sure the compiler command line, version and error output are in plain text, so that we don't have to decode the bug report in order to tell who should take care of it. A meaningful subject indicating language and platform also helps.

Please avoid posting an archive (.tar, .shar or .zip); we generally need just a single file to reproduce the bug (the .i/.ii preprocessed file), and, by storing it in an archive, you're just making our volunteers' jobs harder. Only when your bug report requires multiple source files to be reproduced should you use an archive. In any case, make sure the compiler version, error message, etc, are included in the body of your bug report as plain text, even if needlessly duplicated as part of an archive.

The gcc lists have message size limits (200 kbytes) and bug reports over those limits will currently be bounced. If your bug is larger than that, please post it directly in GNATS.

If you fail to supply enough information for a bug report to be reproduced, someone will probably ask you to post additional information (or just ignore your bug report, if they're in a bad day, so try to get it right on the first posting :-). In this case, please post the additional information to the bug reporting mailing list, not just to the person who requested it, unless explicitly told so. If possible, please include in this follow-up all the information you had supplied in the incomplete bug report (including the preprocessor output), so that the new bug report is self-contained.

Managing Bugs (GNATS and the test-suite)

This section contains information mostly intended for GCC contributors.

If you find a bug, but you are not fixing it (yet):

  1. Create a (minimal) test-case.
  2. Add the test-case to our test-suite, marking it as XFAIL.
  3. Add a bug report referencing the test-case to GNATS.

If you fix a bug for which there is already a GNATS entry:

  1. Remove the XFAIL on the test-case.
  2. Close the bug report in GNATS.

If you find a bug, and you are fixing it right then:

  1. Create a (minimal) test-case.
  2. Add the test-case to our test-suite, marking it as PASS.
  3. Check in your fixes.

Frequently Reported Bugs in GCC 3.0

General

The following bugs are very frequently reported.

Fortran

Fortran bugs are documented in the G77 manual rather than explicitly listed here. Please see "Known Causes of Trouble with GNU Fortran" in the G77 manual.

C++

This is the list of bugs (and non-bugs) in g++ (aka GNU C++) that are reported very often, but not yet fixed. 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 the bug is already well-known. How to report bugs tells you how to report a bug.

There are many reasons why reported bugs don't get fixed. It might be difficult to fix, or fixing it might break compatibility. Often, reports get a low priority when there is a simple work-around. In particular, bugs caused by invalid C++ code have a simple work-around, fix the code. Now that there is an agreed ISO/ANSI standard for C++, the compiler has a definitive document to adhere to. Earlier versions might have accepted source code that is no longer C++. This means that code which might have `worked' in a previous version, is now rejected. You should update your code to be C++.

You should try to use the latest stable release of the GNU C++ compiler. This is currently 3.0. Many commonly reported bugs in earlier releases are fixed in that version.

Common problems updating from g++ 2.95 to g++ 3.0

g++ 3.0 conforms much closer to the ISO C++ standard (available at http://www.ncits.org/cplusplus.htm). We have also implemented some of the core and library defect reports (available at http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_defects.html & http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html respectively).

This means you may get lots of errors about things like strcmp not being found. You've most likely forgotton to tell the compiler to look in the std:: namespace. There are several ways to do this,

Non-bugs

Here are some features that have been reported as bugs, but are not.
Nested classes can access private types of the containing class.
G++ now implements type access control on member types. Defect report 45 clarifies that nested classes are members of the class they are nested in, and so are granted access to private members of that class.
Classes in exception specifiers must be complete types.
[15.4]/1 tells you that you cannot have an incomplete type, or pointer to incomplete (other than cv void *) in an exception specification.
G++ emits two copies of constructors and destructors.
In general there are three types of constructor (and destructor).
  1. The complete object constructor/destructor.
  2. The base object constructor/destructor.
  3. The allocating destructor/deallocating destructor.
The first two are different, when virtual base classes are involved. In some cases we can do better, and this is logged in GNATS.
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 cannot throw an exception in one thread and catch it in another. You cannot throw an exception from a signal handler, and catch it in the main thread.
Global destructors are not run in the correct order
Global destructors should be run in the reverse order of their constructors completing. In most cases this is the same as the reverse order of constructors starting, but sometimes it is different, and that is important. You need to compile and link your programs with --use-cxa-atexit. We have not turned this switch on by default, as it requires a cxa aware runtime library (libc, glibc, or equivalent).

Missing features

We know some things are missing from g++.
export is not implemented.
The keyword will be parsed correctly, but has no effect.
Two stage lookup in templates is not implemented.
[14.6] specifies how names are looked up inside a template. G++ does not do this correctly, but for most templates this will not be noticeable.

Parse errors for "simple" code

Up to and including GCC 3.0, the compiler will give "parse error" for seemingly simple code, such as
struct A{
  A();
  A(int);
  void func();
};

struct B{
  B(A);
  B(A,A);
  void func();
};

void foo(){
  B b(A(),A(1));     //Variable b, initialized with two temporaries
  B(A(2)).func();    //B temporary, initialized with A temporary
}
The problem is that GCC starts to parse the declaration of b as a function b returning B, taking a function returning A as an argument. When it sees the 1, it is too late. The work-around in these cases is to add additional parentheses around the expressions that are mistaken as declarations:
  (B(A(2))).func();
Sometimes, even that is not enough; to show the compiler that this should be really an expression, a comma operator with a dummy argument can be used:
  B b((0,A()),A(1));

Another example is the parse error for the return statement in

struct A{};

struct B{
  A a;
  A f1(bool);
};

A B::f1(bool b)
{
  if (b)
    return (A()); 
  return a;
}

The problem is that the compiler interprets A() as a function (taking no arguments, returning A), and (A()) as a cast - with a missing expression, hence the parse error. The work-around is to omit the parentheses:

  if (b)
    return A(); 

This problem occurs in a number of variants; in throw statements, people also frequently put the object in parentheses. The exact error also somewhat varies with the compiler version. The work-arounds proposed do not change the semantics of the program at all; they make them perhaps less readable.

Optimization at -O3 takes a very long time

At -O3, all functions are candidates for inlining. The heuristic used has some deficiencies which show up when allowed such freedom. This is g++ specific, as it has an earlier inliner than gcc.