This document is a modification from !gcc.docs.gccuser of the
*Reporting Bugs* section. Please use the information supplied here
rather than in !gcc.docs.gccuser.

Throughout the document, reference is make to GCC. This is a collective
term used to describe GNU C, Obj-C, C++, GNAT Ada and Fortran. In the
section *Where to report bugs* is a list of e-mail addresses for where
bugs should be sent depending on the particular compiler you are using.

Reporting Bugs
**************

   Your bug reports play an essential role in making GCC reliable.

   When you encounter a problem, the first thing to do is to see if it
is already known.  If it isn't known, then you should report the problem.

   Reporting a bug may help you by bringing a solution to your problem,
or it may not.  In any case, the principal function of a bug report
is to help the entire community by making the next version of GCC
work better.  Bug reports are your contribution to the maintenance of
GCC and should be sent by e-mail to one of the relevant addresses in the
section *Where to report bugs*. If you do not have access to e-mail, then
try posting the problem to one of the porters postal addresses. 

   Since the maintainers are very overloaded, we cannot respond to every
bug report, although we will try to cure as many as possible.

   In order for a bug report to serve its purpose, you must include the
information that makes for fixing the bug.

Have You Found a Bug?
=====================

   If you are not sure whether you have found a bug, here are some
guidelines:

   * If the compiler gets a fatal signal, for any input whatever, that
     is a compiler bug.  Reliable compilers never crash.

   * If the compiler produces invalid assembly code, for any input
     whatever (except an `asm' statement), that is a compiler bug,
     unless the compiler reports errors (not just warnings) which would
     ordinarily prevent the assembler from being run.

   * If the compiler produces valid assembly code that does not
     correctly execute the input source code, that is a compiler bug.

     However, you must double-check to make sure, because you may have
     run into an incompatibility between the GNU language implementation
     and the traditional language implementation.  These incompatibilities
     might be considered bugs, but they are inescapable consequences of
     valuable features.

     Or you may have a program whose behavior is undefined, which
     happened by chance to give the desired results with another third
     party compiler.

     For example, whilst using C, in many nonoptimizing compilers, you
     can write `x;' at the end of a function instead of `return x;', with
     the same results.  But the value of the function is undefined if
     `return' is omitted; it is not a bug when GNU C produces different
     results.

     Problems often result from expressions with two increment
     operators, as in `f (*p++, *p++)'.  Your previous compiler might
     have interpreted that expression the way you intended; GNU CC might
     interpret it another way.  Neither compiler is wrong.  The bug is
     in your code.

     After you have localized the error to a single source line, it
     should be easy to check for these things.  If your program is
     correct and well defined, you have found a compiler bug.

   * If the compiler produces an error message for valid input, that is
     a compiler bug.

   * If the compiler does not produce an error message for invalid
     input, that is a compiler bug.  However, you should note that your
     idea of "invalid input" might be my idea of "an extension" or
     "support for traditional practice".

   * If you are an experienced user of other language compilers, your
     suggestions for improvement of the equivalent GNU compilers are
     always welcome.

Where to Report Bugs
====================

Different people have ported different compilers. Here is list of the
e-mail addresses you should should when reporting a possible bug.

Bug reports relating to GNU C, GNU C++, GNU Objective-C, GNU Fortran
and GNU Pascal should be sent to:
  Nick Burrett: gcc-bugs@hard-mofo.dsvr.net

Bug reports relating to GNU GNAT Ada should be sent to:
  Peter Burwood: gnat@arcangel.dircon.co.uk

   *Do not send bug reports to `help-gcc@prep.ai.mit.edu' or to the
newsgroup `gnu.gcc.help'.* Most users of GNU CC do not want to receive
bug reports.


How to Report Bugs
==================

   The fundamental principle of reporting bugs usefully is this:
*report all the facts*.  If you are not sure whether to state a fact or
leave it out, state it!

   Often people omit facts because they think they know what causes the
problem and they conclude that some details don't matter.  Thus, you
might assume that the name of the variable you use in an example does
not matter.  Well, probably it doesn't, but one cannot be sure.
Perhaps the bug is a stray memory reference which happens to fetch from
the location where that name is stored in memory; perhaps, if the name
were different, the contents of that location would fool the compiler
into doing the right thing despite the bug.  Play it safe and give a
specific, complete example.  That is the easiest thing for you to do,
and the most helpful.

   Keep in mind that the purpose of a bug report is to enable someone to
fix the bug if it is not known.  It isn't very important what happens if
the bug is already known.  Therefore, always write your bug reports on
the assumption that the bug is not known.

   Sometimes people give a few sketchy facts and ask, "Does this ring a
bell?"  This cannot help us fix a bug, so it is basically useless.  We
respond by asking for enough details to enable us to investigate.  You
might as well expedite matters by sending them to begin with.

   Try to make your bug report self-contained.  If we have to ask you
for more information, it is best if you include all the previous
information in your response, as well as the information that was
missing.

   Please report each bug in a separate message.  This makes it easier
for us to track which bugs have been fixed and to forward your bugs
reports to the appropriate maintainer.

   To enable someone to investigate the bug, you should include all
these things:

   * The version of GCC.  You can get this by running it with the
     `-v' option.

     Without this, we won't know whether there is any point in looking
     for the bug in the current version of GNU CC.
     
     Please include the ARM/RISC OS backend version e.g.
     
     GNU C version 2.7.2 (ARM/RISC OS v1.0.5)
     
     GCC version is 2.7.2.
     ARM/RISC OS backend version is 1.0.5.

   * A complete input file that will reproduce the bug.  If the bug is
     in the C preprocessor, send a source file and any header files
     that it requires.  If the bug is in the compiler proper (`cc1'),
     run your source file through the C preprocessor by doing `gcc -E
     SOURCEFILE > OUTFILE', then include the contents of OUTFILE in the
     bug report.  (When you do this, use the same `-I', `-D' or `-U'
     options that you used in actual compilation.)

     A single statement is not enough of an example.  In order to
     compile it, it must be embedded in a complete file of compiler
     input; and the bug might depend on the details of how this is done.

     Without a real example one can compile, all anyone can do about
     your bug report is wish you luck.  It would be futile to try to
     guess how to provoke the bug.  For example, bugs in register
     allocation and reloading frequently depend on every little detail
     of the function they happen in.

     The problem may depend on what is in the header files on your system;
     it is unreliable for the GCC maintainers to try the problem with the
     header files available to them.  By sending CPP output, you can
     eliminate this source of uncertainty and save us a certain
     percentage of wild goose chases.

   * The command arguments you gave GCC to compile that
     example and observe the bug.  For example, did you use `-O'?  To
     guarantee you won't omit something important, list all the options.

     If we were to try to guess the arguments, we would probably guess
     wrong and then we would not encounter the bug.

   * The type of machine you are using, and the operating system name
     and version number.

   * A description of what behavior you observe that you believe is
     incorrect.  For example, "The compiler gets a fatal signal," or,
     "The assembler instruction at line 208 in the output is incorrect."

     Of course, if the bug is that the compiler gets a fatal signal,
     then one can't miss it.  But if the bug is incorrect output, the
     maintainer might not notice unless it is glaringly wrong.  None of
     us has time to study all the assembler code from a 50-line C
     program just on the chance that one instruction might be wrong.
     We need *you* to do this part!

     Even if the problem you experience is a fatal signal, you should
     still say so explicitly.  Suppose something strange is going on,
     such as you have encountered a bug in the C library on your system.
     (This has happened!)  Your copy might crash and the copy here would
     not.  If you said to expect a crash, then when the compiler here fails
     to crash, we would know that the bug was not happening.  If you don't
     say to expect a crash, then we would not know whether the bug was
     happening.  We would not be able to draw any conclusion from our
     observations.

     Often the observed symptom is incorrect output when your program
     is run.  Sad to say, this is not enough information unless the
     program is short and simple.  None of us has time to study a large
     program to figure out how it would work if compiled correctly,
     much less which line of it was compiled wrong.  So you will have
     to do that.  Tell us which source line it is, and what incorrect
     result happens when that line is executed.  A person who
     understands the program can find this as easily as finding a bug
     in the program itself.

   Here are some things that are not necessary:

   * A description of the envelope of the bug.

     Often people who encounter a bug spend a lot of time investigating
     which changes to the input file will make the bug go away and which
     changes will not affect it.

     This is often time consuming and not very useful, because the way
     we will find the bug is by running a single example under the
     debugger with breakpoints, not by pure deduction from a series of
     examples.  You might as well save your time for something else.

     Of course, if you can find a simpler example to report *instead* of
     the original one, that is a convenience.  Errors in the output
     will be easier to spot, running under the debugger will take less
     time, etc.  Most GCC bugs involve just one function, so the
     most straightforward way to simplify an example is to delete all
     the function definitions except the one where the bug occurs.
     Those earlier in the file may be replaced by external declarations
     if the crucial function depends on them.  (Exception: inline
     functions may affect compilation of functions defined later in the
     file.)

     However, simplification is not vital; if you don't want to do this,
     report the bug anyway and send the entire test case you used.

   * In particular, some people insert conditionals `#ifdef BUG' around
     a statement which, if removed, makes the bug not happen.  These
     are just clutter; we won't pay any attention to them anyway.
     Besides, you should send us cpp output, and that can't have
     conditionals.
