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

   Your bug reports play an essential role in making GNAT 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 GNAT
work better.  Bug reports are your contribution to the maintenance of
GNAT and should be sent by e-mail to gnat@arcangel.dircon.co.uk. If you
don't have access to e-mail, then post them to me at the address in the
!gcc.gnat.Help file.

   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 an
     erroneous program which doesn't raise PROGRAM_ERROR.
     
     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 Ada compilers, your suggestions
     for improvement of GNAT are welcome in any case.

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

   Send bug reports for GNAT to gnat@arcangel.dircon.co.uk.

   Send bug reports for GNU C++ to nickb@digibank.demon.co.uk.  If your
bug involves the C++ class library libg++, send mail to
bug-lib-g++@prep.ai.mit.edu.  If you're not sure, you can send the
bug report to both addresses.

   *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 GNAT.  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 GNAT.

   * A complete input file that will reproduce the bug.  For a report
     that contains multiple separate compilation units, and hence
     multiple files, submit them in the form of a single file that is
     acceptable input to gnatchop, i.e., contains no non-Ada text. If you
     use banners to separate the files, make sure they are composed
     entirely of blank lines or Ada comments.
     
     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.

     If you want to be maximally helpful, try to reduce your example to a
     simple one but DON'T spend too much time doing this.  Especially when
     you are reporting a blow up during compilation, rather than bad code
     generated, we can in practice work with big sources if you have
     trouble narrowing things down.

   * The command arguments you gave GNAT or one of the GNAT tools 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 Ada
     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.

     If a bug involves incorrect operation of the generated code, then
     the first thing the program should do is to output a line
     indicating the expected output or behavior.  If at all possible, do
     a test later on that prints out "passed" or "failed" depending on
     the behavior. Of course it may not always be possible to structure
     a test this way, but that's the most  convenient form (for obvious
     reasons!)

   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 GNAT 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.
