home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / msdos / djgpp / docs / gcc / gcc.i8 < prev    next >
Encoding:
GNU Info File  |  1993-05-29  |  46.5 KB  |  1,050 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.54 from the input
  2. file gcc.texi.
  3.  
  4.    This file documents the use and the internals of the GNU compiler.
  5.  
  6.    Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
  7.  
  8.    Permission is granted to make and distribute verbatim copies of this
  9. manual provided the copyright notice and this permission notice are
  10. preserved on all copies.
  11.  
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided also
  14. that the sections entitled "GNU General Public License" and "Protect
  15. Your Freedom--Fight `Look And Feel'" are included exactly as in the
  16. original, and provided that the entire resulting derived work is
  17. distributed under the terms of a permission notice identical to this
  18. one.
  19.  
  20.    Permission is granted to copy and distribute translations of this
  21. manual into another language, under the above conditions for modified
  22. versions, except that the sections entitled "GNU General Public
  23. License" and "Protect Your Freedom--Fight `Look And Feel'", and this
  24. permission notice, may be included in translations approved by the Free
  25. Software Foundation instead of in the original English.
  26.  
  27. 
  28. File: gcc.info,  Node: Disappointments,  Next: C++ Misunderstandings,  Prev: Incompatibilities,  Up: Trouble
  29.  
  30. Disappointments and Misunderstandings
  31. =====================================
  32.  
  33.    These problems are perhaps regrettable, but we don't know any
  34. practical way around them.
  35.  
  36.    * Certain local variables aren't recognized by debuggers when you
  37.      compile with optimization.
  38.  
  39.      This occurs because sometimes GNU CC optimizes the variable out of
  40.      existence.  There is no way to tell the debugger how to compute the
  41.      value such a variable "would have had", and it is not clear that
  42.      would be desirable anyway.  So GNU CC simply does not mention the
  43.      eliminated variable when it writes debugging information.
  44.  
  45.      You have to expect a certain amount of disagreement between the
  46.      executable and your source code, when you use optimization.
  47.  
  48.    * Users often think it is a bug when GNU CC reports an error for code
  49.      like this:
  50.  
  51.           int foo (struct mumble *);
  52.           
  53.           struct mumble { ... };
  54.           
  55.           int foo (struct mumble *x)
  56.           { ... }
  57.  
  58.      This code really is erroneous, because the scope of `struct
  59.      mumble' in the prototype is limited to the argument list
  60.      containing it.  It does not refer to the `struct mumble' defined
  61.      with file scope immediately below--they are two unrelated types
  62.      with similar names in different scopes.
  63.  
  64.      But in the definition of `foo', the file-scope type is used
  65.      because that is available to be inherited.  Thus, the definition
  66.      and the prototype do not match, and you get an error.
  67.  
  68.      This behavior may seem silly, but it's what the ANSI standard
  69.      specifies.  It is easy enough for you to make your code work by
  70.      moving the definition of `struct mumble' above the prototype.
  71.      It's not worth being incompatible with ANSI C just to avoid an
  72.      error for the example shown above.
  73.  
  74.    * Accesses to bitfields even in volatile objects works by accessing
  75.      larger objects, such as a byte or a word.  You cannot rely on what
  76.      size of object is accessed in order to read or write the bitfield;
  77.      it may even vary for a given bitfield according to the precise
  78.      usage.
  79.  
  80.      If you care about controlling the amount of memory that is
  81.      accessed, use volatile but do not use bitfields.
  82.  
  83.    * GNU CC comes with shell scripts to fix certain known problems in
  84.      system header files.  They install corrected copies of various
  85.      header files in a special directory where only GNU CC will
  86.      normally look for them.  The scripts adapt to various systems by
  87.      searching all the system header files for the problem cases that
  88.      we know about.
  89.  
  90.      If new system header files are installed, nothing automatically
  91.      arranges to update the corrected header files.  You will have to
  92.      reinstall GNU CC to fix the new header files.  More specifically,
  93.      go to the build directory and delete the files `stmp-fixinc' and
  94.      `stmp-headers', and the subdirectory `include'; then do `make
  95.      install' again.
  96.  
  97.    * On 68000 systems, you can get paradoxical results if you test the
  98.      precise values of floating point numbers.  For example, you can
  99.      find that a floating point value which is not a NaN is not equal
  100.      to itself.  This results from the fact that the the floating point
  101.      registers hold a few more bits of precision than fit in a `double'
  102.      in memory.  Compiled code moves values between memory and floating
  103.      point registers at its convenience, and moving them into memory
  104.      truncates them.
  105.  
  106.      You can partially avoid this problem by using the `-ffloat-store'
  107.      option (*note Optimize Options::.).
  108.  
  109.    * On the MIPS, variable argument functions using `varargs.h' cannot
  110.      have a floating point value for the first argument.  The reason
  111.      for this is that in the absence of a prototype in scope, if the
  112.      first argument is a floating point, it is passed in a floating
  113.      point register, rather than an integer register.
  114.  
  115.      If the code is rewritten to use the ANSI standard `stdarg.h'
  116.      method of variable arguments, and the prototype is in scope at the
  117.      time of the call, everything will work fine.
  118.  
  119. 
  120. File: gcc.info,  Node: C++ Misunderstandings,  Next: Protoize Caveats,  Prev: Disappointments,  Up: Trouble
  121.  
  122. Common Misunderstandings with GNU C++
  123. =====================================
  124.  
  125.    C++ is a complex language and an evolving one, and its standard
  126. definition (the ANSI C++ draft standard) is also evolving.  As a result,
  127. your C++ compiler may occasionally surprise you, even when its behavior
  128. is correct.  This section discusses some areas that frequently give
  129. rise to questions of this sort.
  130.  
  131. * Menu:
  132.  
  133. * Static Definitions::  Static member declarations are not definitions
  134. * Temporaries::         Temporaries may vanish before you expect
  135.  
  136. 
  137. File: gcc.info,  Node: Static Definitions,  Next: Temporaries,  Up: C++ Misunderstandings
  138.  
  139. Declare *and* Define Static Members
  140. -----------------------------------
  141.  
  142.    When a class has static data members, it is not enough to *declare*
  143. the static member; you must also *define* it.  For example:
  144.  
  145.      class Foo
  146.      {
  147.        ...
  148.        void method();
  149.        static int bar;
  150.      };
  151.  
  152.    This declaration only establishes that the class `Foo' has an `int'
  153. named `Foo::bar', and a member function named `Foo::method'.  But you
  154. still need to define *both* `method' and `bar' elsewhere.  According to
  155. the draft ANSI standard, you must supply an initializer in one (and
  156. only one) source file, such as:
  157.  
  158.      int Foo::bar = 0;
  159.  
  160.    Other C++ compilers may not correctly implement the standard
  161. behavior.  As a result, when you switch to `g++' from one of these
  162. compilers, you may discover that a program that appeared to work
  163. correctly in fact does not conform to the standard: `g++' reports as
  164. undefined symbols any static data members that lack definitions.
  165.  
  166. 
  167. File: gcc.info,  Node: Temporaries,  Prev: Static Definitions,  Up: C++ Misunderstandings
  168.  
  169. Temporaries May Vanish Before You Expect
  170. ----------------------------------------
  171.  
  172.    It is dangerous to use pointers or references to *portions* of a
  173. temporary object.  The compiler may very well delete the object before
  174. you expect it to, leaving a pointer to garbage.  The most common place
  175. where this problem crops up is in classes like the libg++ `String'
  176. class, that define a conversion function to type `char *' or `const
  177. char *'.  However, any class that returns a pointer to some internal
  178. structure is potentially subject to this problem.
  179.  
  180.    For example, a program may use a function `strfunc' that returns
  181. `String' objects, and another function `charfunc' that operates on
  182. pointers to `char':
  183.  
  184.      String strfunc ();
  185.      void charfunc (const char *);
  186.  
  187. In this situation, it may seem natural to write
  188. `charfunc (strfunc ());' based on the knowledge that class `String' has
  189. an explicit conversion to `char' pointers.  However, what really
  190. happens is akin to `charfunc (strfunc ().convert ());', where the
  191. `convert' method is a function to do the same data conversion normally
  192. performed by a cast.  Since the last use of the temporary `String'
  193. object is the call to the conversion function, the compiler may delete
  194. that object before actually calling `charfunc'.  The compiler has no
  195. way of knowing that deleting the `String' object will invalidate the
  196. pointer.  The pointer then points to garbage, so that by the time
  197. `charfunc' is called, it gets an invalid argument.
  198.  
  199.    Code like this may run successfully under some other compilers,
  200. especially those that delete temporaries relatively late.  However, the
  201. GNU C++ behavior is also standard-conformant, so if your program depends
  202. on late destruction of temporaries it is not portable.
  203.  
  204.    If you think this is surprising, you should be aware that the ANSI
  205. C++ committee continues to debate the lifetime-of-temporaries problem.
  206.  
  207.    For now, at least, the safe way to write such code is to give the
  208. temporary a name, which forces it to remain until the end of the scope
  209. of the name.  For example:
  210.  
  211.      String& tmp = strfunc ();
  212.      charfunc (tmp);
  213.  
  214. 
  215. File: gcc.info,  Node: Protoize Caveats,  Next: Non-bugs,  Prev: C++ Misunderstandings,  Up: Trouble
  216.  
  217. Caveats of using `protoize'
  218. ===========================
  219.  
  220.    The conversion programs `protoize' and `unprotoize' can sometimes
  221. change a source file in a way that won't work unless you rearrange it.
  222.  
  223.    * `protoize' can insert references to a type name or type tag before
  224.      the definition, or in a file where they are not defined.
  225.  
  226.      If this happens, compiler error messages should show you where the
  227.      new references are, so fixing the file by hand is straightforward.
  228.  
  229.    * There are some C constructs which `protoize' cannot figure out.
  230.      For example, it can't determine argument types for declaring a
  231.      pointer-to-function variable; this you must do by hand.  `protoize'
  232.      inserts a comment containing `???' each time it finds such a
  233.      variable; so you can find all such variables by searching for this
  234.      string.  ANSI C does not require declaring the argument types of
  235.      pointer-to-function types.
  236.  
  237.    * Using `unprotoize' can easily introduce bugs.  If the program
  238.      relied on prototypes to bring about conversion of arguments, these
  239.      conversions will not take place in the program without prototypes.
  240.      One case in which you can be sure `unprotoize' is safe is when you
  241.      are removing prototypes that were made with `protoize'; if the
  242.      program worked before without any prototypes, it will work again
  243.      without them.
  244.  
  245.      You can find all the places where this problem might occur by
  246.      compiling the program with the `-Wconversion' option.  It prints a
  247.      warning whenever an argument is converted.
  248.  
  249.    * Both conversion programs can be confused if there are macro calls
  250.      in and around the text to be converted.  In other words, the
  251.      standard syntax for a declaration or definition must not result
  252.      from expanding a macro.  This problem is inherent in the design of
  253.      C and cannot be fixed.  If only a few functions have confusing
  254.      macro calls, you can easily convert them manually.
  255.  
  256.    * `protoize' cannot get the argument types for a function whose
  257.      definition was not actually compiled due to preprocessor
  258.      conditionals.  When this happens, `protoize' changes nothing in
  259.      regard to such a function.  `protoize' tries to detect such
  260.      instances and warn about them.
  261.  
  262.      You can generally work around this problem by using `protoize' step
  263.      by step, each time specifying a different set of `-D' options for
  264.      compilation, until all of the functions have been converted.
  265.      There is no automatic way to verify that you have got them all,
  266.      however.
  267.  
  268.    * Confusion may result if there is an occasion to convert a function
  269.      declaration or definition in a region of source code where there
  270.      is more than one formal parameter list present.  Thus, attempts to
  271.      convert code containing multiple (conditionally compiled) versions
  272.      of a single function header (in the same vicinity) may not produce
  273.      the desired (or expected) results.
  274.  
  275.      If you plan on converting source files which contain such code, it
  276.      is recommended that you first make sure that each conditionally
  277.      compiled region of source code which contains an alternative
  278.      function header also contains at least one additional follower
  279.      token (past the final right parenthesis of the function header).
  280.      This should circumvent the problem.
  281.  
  282.    * `unprotoize' can become confused when trying to convert a function
  283.      definition or declaration which contains a declaration for a
  284.      pointer-to-function formal argument which has the same name as the
  285.      function being defined or declared.  We recommand you avoid such
  286.      choices of formal parameter names.
  287.  
  288.    * You might also want to correct some of the indentation by hand and
  289.      break long lines.  (The conversion programs don't write lines
  290.      longer than eighty characters in any case.)
  291.  
  292. 
  293. File: gcc.info,  Node: Non-bugs,  Next: Warnings and Errors,  Prev: Protoize Caveats,  Up: Trouble
  294.  
  295. Certain Changes We Don't Want to Make
  296. =====================================
  297.  
  298.    This section lists changes that people frequently request, but which
  299. we do not make because we think GNU CC is better without them.
  300.  
  301.    * Checking the number and type of arguments to a function which has
  302.      an old-fashioned definition and no prototype.
  303.  
  304.      Such a feature would work only occasionally--only for calls that
  305.      appear in the same file as the called function, following the
  306.      definition.  The only way to check all calls reliably is to add a
  307.      prototype for the function.  But adding a prototype eliminates the
  308.      motivation for this feature.  So the feature is not worthwhile.
  309.  
  310.    * Warning about using an expression whose type is signed as a shift
  311.      count.
  312.  
  313.      Shift count operands are probably signed more often than unsigned.
  314.      Warning about this would cause far more annoyance than good.
  315.  
  316.    * Warning about assigning a signed value to an unsigned variable.
  317.  
  318.      Such assignments must be very common; warning about them would
  319.      cause more annoyance than good.
  320.  
  321.    * Warning about unreachable code.
  322.  
  323.      It's very common to have unreachable code in machine-generated
  324.      programs.  For example, this happens normally in some files of GNU
  325.      C itself.
  326.  
  327.    * Warning when a non-void function value is ignored.
  328.  
  329.      Coming as I do from a Lisp background, I balk at the idea that
  330.      there is something dangerous about discarding a value.  There are
  331.      functions that return values which some callers may find useful;
  332.      it makes no sense to clutter the program with a cast to `void'
  333.      whenever the value isn't useful.
  334.  
  335.    * Assuming (for optimization) that the address of an external symbol
  336.      is never zero.
  337.  
  338.      This assumption is false on certain systems when `#pragma weak' is
  339.      used.
  340.  
  341.    * Making `-fshort-enums' the default.
  342.  
  343.      This would cause storage layout to be incompatible with most other
  344.      C compilers.  And it doesn't seem very important, given that you
  345.      can get the same result in other ways.  The case where it matters
  346.      most is when the enumeration-valued object is inside a structure,
  347.      and in that case you can specify a field width explicitly.
  348.  
  349.    * Making bitfields unsigned by default on particular machines where
  350.      "the ABI standard" says to do so.
  351.  
  352.      The ANSI C standard leaves it up to the implementation whether a
  353.      bitfield declared plain `int' is signed or not.  This in effect
  354.      creates two alternative dialects of C.
  355.  
  356.      The GNU C compiler supports both dialects; you can specify the
  357.      dialect you want with the option `-fsigned-bitfields' or
  358.      `-funsigned-bitfields'.  However, this leaves open the question of
  359.      which dialect to use by default.
  360.  
  361.      Currently, the preferred dialect makes plain bitfields signed,
  362.      because this is simplest.  Since `int' is the same as `signed int'
  363.      in every other context, it is cleanest for them to be the same in
  364.      bitfields as well.
  365.  
  366.      Some computer manufacturers have published Application Binary
  367.      Interface standards which specify that plain bitfields should be
  368.      unsigned.  It is a mistake, however, to say anything about this
  369.      issue in an ABI.  This is because the handling of plain bitfields
  370.      distinguishes two dialects of C.  Both dialects are meaningful on
  371.      every type of machine.  Whether a particular object file was
  372.      compiled using signed bitfields or unsigned is of no concern to
  373.      other object files, even if they access the same bitfields in the
  374.      same data structures.
  375.  
  376.      A given program is written in one or the other of these two
  377.      dialects.  The program stands a chance to work on most any machine
  378.      if it is compiled with the proper dialect.  It is unlikely to work
  379.      at all if compiled with the wrong dialect.
  380.  
  381.      Many users appreciate the GNU C compiler because it provides an
  382.      environment that is uniform across machines.  These users would be
  383.      inconvenienced if the compiler treated plain bitfields differently
  384.      on certain machines.
  385.  
  386.      Occasionally users write programs intended only for a particular
  387.      machine type.  On these occasions, the users would benefit if the
  388.      GNU C compiler were to support by default the same dialect as the
  389.      other compilers on that machine.  But such applications are rare.
  390.      And users writing a program to run on more than one type of
  391.      machine cannot possibly benefit from this kind of compatibility.
  392.  
  393.      This is why GNU CC does and will treat plain bitfields in the same
  394.      fashion on all types of machines (by default).
  395.  
  396.      There are some arguments for making bitfields unsigned by default
  397.      on all machines.  If, for example, this becomes a universal de
  398.      facto standard, it would make sense for GNU CC to go along with
  399.      it.  This is something to be considered in the future.
  400.  
  401.      (Of course, users strongly concerned about portability should
  402.      indicate explicitly in each bitfield whether it is signed or not.
  403.      In this way, they write programs which have the same meaning in
  404.      both C dialects.)
  405.  
  406.    * Undefining `__STDC__' when `-ansi' is not used.
  407.  
  408.      Currently, GNU CC defines `__STDC__' as long as you don't use
  409.      `-traditional'.  This provides good results in practice.
  410.  
  411.      Programmers normally use conditionals on `__STDC__' to ask whether
  412.      it is safe to use certain features of ANSI C, such as function
  413.      prototypes or ANSI token concatenation.  Since plain `gcc' supports
  414.      all the features of ANSI C, the correct answer to these questions
  415.      is "yes".
  416.  
  417.      Some users try to use `__STDC__' to check for the availability of
  418.      certain library facilities.  This is actually incorrect usage in
  419.      an ANSI C program, because the ANSI C standard says that a
  420.      conforming freestanding implementation should define `__STDC__'
  421.      even though it does not have the library facilities.  `gcc -ansi
  422.      -pedantic' is a conforming freestanding implementation, and it is
  423.      therefore required to define `__STDC__', even though it does not
  424.      come with an ANSI C library.
  425.  
  426.      Sometimes people say that defining `__STDC__' in a compiler that
  427.      does not completely conform to the ANSI C standard somehow
  428.      violates the standard.  This is illogical.  The standard is a
  429.      standard for compilers that claim to support ANSI C, such as `gcc
  430.      -ansi'--not for other compilers such as plain `gcc'.  Whatever the
  431.      ANSI C standard says is relevant to the design of plain `gcc'
  432.      without `-ansi' only for pragmatic reasons, not as a requirement.
  433.  
  434.    * Undefining `__STDC__' in C++.
  435.  
  436.      Programs written to compile with C++-to-C translators get the
  437.      value of `__STDC__' that goes with the C compiler that is
  438.      subsequently used.  These programs must test `__STDC__' to
  439.      determine what kind of C preprocessor that compiler uses: whether
  440.      they should concatenate tokens in the ANSI C fashion or in the
  441.      traditional fashion.
  442.  
  443.      These programs work properly with GNU C++ if `__STDC__' is defined.
  444.      They would not work otherwise.
  445.  
  446.      In addition, many header files are written to provide prototypes
  447.      in ANSI C but not in traditional C.  Many of these header files
  448.      can work without change in C++ provided `__STDC__' is defined.  If
  449.      `__STDC__' is not defined, they will all fail, and will all need
  450.      to be changed to test explicitly for C++ as well.
  451.  
  452.    * Deleting "empty" loops.
  453.  
  454.      GNU CC does not delete "empty" loops because the most likely reason
  455.      you would put one in a program is to have a delay.  Deleting them
  456.      will not make real programs run any faster, so it would be
  457.      pointless.
  458.  
  459.      It would be different if optimization of a nonempty loop could
  460.      produce an empty one.  But this generally can't happen.
  461.  
  462.    * Making side effects happen in the same order as in some other
  463.      compiler.
  464.  
  465.      It is never safe to depend on the order of evaluation of side
  466.      effects.  For example, a function call like this may very well
  467.      behave differently from one compiler to another:
  468.  
  469.           void func (int, int);
  470.           
  471.           int i = 2;
  472.           func (i++, i++);
  473.  
  474.      There is no guarantee (in either the C or the C++ standard language
  475.      definitions) that the increments will be evaluated in any
  476.      particular order.  Either increment might happen first.  `func'
  477.      might get the arguments `3, 4', or it might get `4, 3', or even
  478.      `3, 3'.
  479.  
  480.    * Using the "canonical" form of the target configuration name as the
  481.      directory for installation.
  482.  
  483.      This would be an improvement in some respects, but it would also
  484.      cause problems.  For one thing, users might expect to use in the
  485.      `-b' option the same name specified at installation; if
  486.      installation used the canonical form, that would not work.  What's
  487.      more, the canonical name might be too long for certain file
  488.      systems.
  489.  
  490.      We suggest you make a link to the installation directory under the
  491.      canonical name, if you want to use that name in the `-b' option.
  492.  
  493. 
  494. File: gcc.info,  Node: Warnings and Errors,  Prev: Non-bugs,  Up: Trouble
  495.  
  496. Warning Messages and Error Messages
  497. ===================================
  498.  
  499.    The GNU compiler can produce two kinds of diagnostics: errors and
  500. warnings.  Each kind has a different purpose:
  501.  
  502.      *Errors* report problems that make it impossible to compile your
  503.      program.  GNU CC reports errors with the source file name and line
  504.      number where the problem is apparent.
  505.  
  506.      *Warnings* report other unusual conditions in your code that *may*
  507.      indicate a problem, although compilation can (and does) proceed.
  508.      Warning messages also report the source file name and line number,
  509.      but include the text `warning:' to distinguish them from error
  510.      messages.
  511.  
  512.    Warnings may indicate danger points where you should check to make
  513. sure that your program really does what you intend; or the use of
  514. obsolete features; or the use of nonstandard features of GNU C or C++.
  515. Many warnings are issued only if you ask for them, with one of the `-W'
  516. options (for instance, `-Wall' requests a variety of useful warnings).
  517.  
  518.    GNU CC always tries to compile your program if possible; it never
  519. gratuituously rejects a program whose meaning is clear merely because
  520. (for instance) it fails to conform to a standard.  In some cases,
  521. however, the C and C++ standards specify that certain extensions are
  522. forbidden, and a diagnostic *must* be issued by a conforming compiler.
  523. The `-pedantic' option tells GNU CC to issue warnings in such cases;
  524. `-pedantic-errors' says to make them errors instead.  This does not
  525. mean that *all* non-ANSI constructs get warnings or errors.
  526.  
  527.    *Note Options to Request or Suppress Warnings: Warning Options, for
  528. more detail on these and related command-line options.
  529.  
  530. 
  531. File: gcc.info,  Node: Bugs,  Next: Service,  Prev: Trouble,  Up: Top
  532.  
  533. Reporting Bugs
  534. **************
  535.  
  536.    Your bug reports play an essential role in making GNU CC reliable.
  537.  
  538.    When you encounter a problem, the first thing to do is to see if it
  539. is already known.  *Note Trouble::.  If it isn't known, then you should
  540. report the problem.
  541.  
  542.    Reporting a bug may help you by bringing a solution to your problem,
  543. or it may not.  (If it does not, look in the service directory; see
  544. *Note Service::.)  In any case, the principal function of a bug report
  545. is to help the entire community by making the next version of GNU CC
  546. work better.  Bug reports are your contribution to the maintenance of
  547. GNU CC.
  548.  
  549.    In order for a bug report to serve its purpose, you must include the
  550. information that makes for fixing the bug.
  551.  
  552. * Menu:
  553.  
  554. * Criteria:  Bug Criteria.   Have you really found a bug?
  555. * Where: Bug Lists.         Where to send your bug report.
  556. * Reporting: Bug Reporting.  How to report a bug effectively.
  557. * Patches: Sending Patches.  How to send a patch for GNU CC.
  558. * Known: Trouble.            Known problems.
  559. * Help: Service.             Where to ask for help.
  560.  
  561. 
  562. File: gcc.info,  Node: Bug Criteria,  Next: Bug Lists,  Up: Bugs
  563.  
  564. Have You Found a Bug?
  565. =====================
  566.  
  567.    If you are not sure whether you have found a bug, here are some
  568. guidelines:
  569.  
  570.    * If the compiler gets a fatal signal, for any input whatever, that
  571.      is a compiler bug.  Reliable compilers never crash.
  572.  
  573.    * If the compiler produces invalid assembly code, for any input
  574.      whatever (except an `asm' statement), that is a compiler bug,
  575.      unless the compiler reports errors (not just warnings) which would
  576.      ordinarily prevent the assembler from being run.
  577.  
  578.    * If the compiler produces valid assembly code that does not
  579.      correctly execute the input source code, that is a compiler bug.
  580.  
  581.      However, you must double-check to make sure, because you may have
  582.      run into an incompatibility between GNU C and traditional C (*note
  583.      Incompatibilities::.).  These incompatibilities might be considered
  584.      bugs, but they are inescapable consequences of valuable features.
  585.  
  586.      Or you may have a program whose behavior is undefined, which
  587.      happened by chance to give the desired results with another C or
  588.      C++ compiler.
  589.  
  590.      For example, in many nonoptimizing compilers, you can write `x;'
  591.      at the end of a function instead of `return x;', with the same
  592.      results.  But the value of the function is undefined if `return'
  593.      is omitted; it is not a bug when GNU CC produces different results.
  594.  
  595.      Problems often result from expressions with two increment
  596.      operators, as in `f (*p++, *p++)'.  Your previous compiler might
  597.      have interpreted that expression the way you intended; GNU CC might
  598.      interpret it another way.  Neither compiler is wrong.  The bug is
  599.      in your code.
  600.  
  601.      After you have localized the error to a single source line, it
  602.      should be easy to check for these things.  If your program is
  603.      correct and well defined, you have found a compiler bug.
  604.  
  605.    * If the compiler produces an error message for valid input, that is
  606.      a compiler bug.
  607.  
  608.    * If the compiler does not produce an error message for invalid
  609.      input, that is a compiler bug.  However, you should note that your
  610.      idea of "invalid input" might be my idea of "an extension" or
  611.      "support for traditional practice".
  612.  
  613.    * If you are an experienced user of C or C++ compilers, your
  614.      suggestions for improvement of GNU CC or GNU C++ are welcome in
  615.      any case.
  616.  
  617. 
  618. File: gcc.info,  Node: Bug Lists,  Next: Bug Reporting,  Prev: Bug Criteria,  Up: Bugs
  619.  
  620. Where to Report Bugs
  621. ====================
  622.  
  623.    Send bug reports for GNU C to one of these addresses:
  624.  
  625.      bug-gcc@prep.ai.mit.edu
  626.      {ucbvax|mit-eddie|uunet}!prep.ai.mit.edu!bug-gcc
  627.  
  628.    Send bug reports for GNU C++ to one of these addresses:
  629.  
  630.      bug-g++@prep.ai.mit.edu
  631.      {ucbvax|mit-eddie|uunet}!prep.ai.mit.edu!bug-g++
  632.  
  633.    If your bug involves the GNU class library libg++ rather than the
  634. compiler, mail to `bug-lib-g++@prep.ai.mit.edu'.  If you're not sure,
  635. you can send your bug report to both lists.
  636.  
  637.    *Do not send bug reports to the mailing list `help-gcc', or to the
  638. newsgroup `gnu.gcc.help'.* Most users of GNU CC do not want to receive
  639. bug reports.  Those that do, have asked to be on `bug-gcc' and/or
  640. `bug-g++'.
  641.  
  642.    The mailing lists `bug-gcc' and `bug-g++' both have newsgroups which
  643. serve as repeaters: `gnu.gcc.bug' and `gnu.g++.bug'.  Each mailing list
  644. and its newsgroup carry exactly the same messages.
  645.  
  646.    Often people think of posting bug reports to the newsgroup instead of
  647. mailing them.  This appears to work, but it has one problem which can be
  648. crucial: a newsgroup posting does not contain a mail path back to the
  649. sender.  Thus, if maintainers need more information, they may be unable
  650. to reach you.  For this reason, you should always send bug reports by
  651. mail to the proper mailing list.
  652.  
  653.    As a last resort, send bug reports on paper to:
  654.  
  655.      GNU Compiler Bugs
  656.      Free Software Foundation
  657.      675 Mass Ave
  658.      Cambridge, MA 02139
  659.  
  660. 
  661. File: gcc.info,  Node: Bug Reporting,  Next: Sending Patches,  Prev: Bug Lists,  Up: Bugs
  662.  
  663. How to Report Bugs
  664. ==================
  665.  
  666.    The fundamental principle of reporting bugs usefully is this:
  667. *report all the facts*.  If you are not sure whether to state a fact or
  668. leave it out, state it!
  669.  
  670.    Often people omit facts because they think they know what causes the
  671. problem and they conclude that some details don't matter.  Thus, you
  672. might assume that the name of the variable you use in an example does
  673. not matter.  Well, probably it doesn't, but one cannot be sure.
  674. Perhaps the bug is a stray memory reference which happens to fetch from
  675. the location where that name is stored in memory; perhaps, if the name
  676. were different, the contents of that location would fool the compiler
  677. into doing the right thing despite the bug.  Play it safe and give a
  678. specific, complete example.  That is the easiest thing for you to do,
  679. and the most helpful.
  680.  
  681.    Keep in mind that the purpose of a bug report is to enable someone to
  682. fix the bug if it is not known.  It isn't very important what happens if
  683. the bug is already known.  Therefore, always write your bug reports on
  684. the assumption that the bug is not known.
  685.  
  686.    Sometimes people give a few sketchy facts and ask, "Does this ring a
  687. bell?"  This cannot help us fix a bug, so it is basically useless.  We
  688. respond by asking for enough details to enable us to investigate.  You
  689. might as well expedite matters by sending them to begin with.
  690.  
  691.    Try to make your bug report self-contained.  If we have to ask you
  692. for more information, it is best if you include all the previous
  693. information in your response, as well as the information that was
  694. missing.
  695.  
  696.    To enable someone to investigate the bug, you should include all
  697. these things:
  698.  
  699.    * The version of GNU CC.  You can get this by running it with the
  700.      `-v' option.
  701.  
  702.      Without this, we won't know whether there is any point in looking
  703.      for the bug in the current version of GNU CC.
  704.  
  705.    * A complete input file that will reproduce the bug.  If the bug is
  706.      in the C preprocessor, send a source file and any header files
  707.      that it requires.  If the bug is in the compiler proper (`cc1'),
  708.      run your source file through the C preprocessor by doing `gcc -E
  709.      SOURCEFILE > OUTFILE', then include the contents of OUTFILE in the
  710.      bug report.  (When you do this, use the same `-I', `-D' or `-U'
  711.      options that you used in actual compilation.)
  712.  
  713.      A single statement is not enough of an example.  In order to
  714.      compile it, it must be embedded in a complete file of compiler
  715.      input; and the bug might depend on the details of how this is done.
  716.  
  717.      Without a real example one can compile, all anyone can do about
  718.      your bug report is wish you luck.  It would be futile to try to
  719.      guess how to provoke the bug.  For example, bugs in register
  720.      allocation and reloading frequently depend on every little detail
  721.      of the function they happen in.
  722.  
  723.      Even if the input file that fails comes from a GNU program, you
  724.      should still send the complete test case.  Don't ask the GNU CC
  725.      maintainers to do the extra work of obtaining the program in
  726.      question--they are all overworked as it is.  Also, the problem may
  727.      depend on what is in the header files on your system; it is
  728.      unreliable for the GNU CC maintainers to try the problem with the
  729.      header files available to them.  By sending CPP output, you can
  730.      eliminate this source of uncertainty and save us a certain
  731.      percentage of wild goose chases.
  732.  
  733.    * The command arguments you gave GNU CC or GNU C++ to compile that
  734.      example and observe the bug.  For example, did you use `-O'?  To
  735.      guarantee you won't omit something important, list all the options.
  736.  
  737.      If we were to try to guess the arguments, we would probably guess
  738.      wrong and then we would not encounter the bug.
  739.  
  740.    * The type of machine you are using, and the operating system name
  741.      and version number.
  742.  
  743.    * The operands you gave to the `configure' command when you installed
  744.      the compiler.
  745.  
  746.    * A complete list of any modifications you have made to the compiler
  747.      source.  (We don't promise to investigate the bug unless it
  748.      happens in an unmodified compiler.  But if you've made
  749.      modifications and don't tell us, then you are sending us on a wild
  750.      goose chase.)
  751.  
  752.      Be precise about these changes.  A description in English is not
  753.      enough--send a context diff for them.
  754.  
  755.      Adding files of your own (such as a machine description for a
  756.      machine we don't support) is a modification of the compiler source.
  757.  
  758.    * Details of any other deviations from the standard procedure for
  759.      installing GNU CC.
  760.  
  761.    * A description of what behavior you observe that you believe is
  762.      incorrect.  For example, "The compiler gets a fatal signal," or,
  763.      "The assembler instruction at line 208 in the output is incorrect."
  764.  
  765.      Of course, if the bug is that the compiler gets a fatal signal,
  766.      then one can't miss it.  But if the bug is incorrect output, the
  767.      maintainer might not notice unless it is glaringly wrong.  None of
  768.      us has time to study all the assembler code from a 50-line C
  769.      program just on the chance that one instruction might be wrong.
  770.      We need *you* to do this part!
  771.  
  772.      Even if the problem you experience is a fatal signal, you should
  773.      still say so explicitly.  Suppose something strange is going on,
  774.      such as, your copy of the compiler is out of synch, or you have
  775.      encountered a bug in the C library on your system.  (This has
  776.      happened!)  Your copy might crash and the copy here would not.  If
  777.      you said to expect a crash, then when the compiler here fails to
  778.      crash, we would know that the bug was not happening.  If you don't
  779.      say to expect a crash, then we would not know whether the bug was
  780.      happening.  We would not be able to draw any conclusion from our
  781.      observations.
  782.  
  783.      If the problem is a diagnostic when compiling GNU CC with some
  784.      other compiler, say whether it is a warning or an error.
  785.  
  786.      Often the observed symptom is incorrect output when your program
  787.      is run.  Sad to say, this is not enough information unless the
  788.      program is short and simple.  None of us has time to study a large
  789.      program to figure out how it would work if compiled correctly,
  790.      much less which line of it was compiled wrong.  So you will have
  791.      to do that.  Tell us which source line it is, and what incorrect
  792.      result happens when that line is executed.  A person who
  793.      understands the program can find this as easily as finding a bug
  794.      in the program itself.
  795.  
  796.    * If you send examples of assembler code output from GNU CC or GNU
  797.      C++, please use `-g' when you make them.  The debugging information
  798.      includes source line numbers which are essential for correlating
  799.      the output with the input.
  800.  
  801.    * If you wish to mention something in the GNU CC source, refer to it
  802.      by context, not by line number.
  803.  
  804.      The line numbers in the development sources don't match those in
  805.      your sources.  Your line numbers would convey no useful
  806.      information to the maintainers.
  807.  
  808.    * Additional information from a debugger might enable someone to
  809.      find a problem on a machine which he does not have available.
  810.      However, you need to think when you collect this information if
  811.      you want it to have any chance of being useful.
  812.  
  813.      For example, many people send just a backtrace, but that is never
  814.      useful by itself.  A simple backtrace with arguments conveys little
  815.      about GNU CC because the compiler is largely data-driven; the same
  816.      functions are called over and over for different RTL insns, doing
  817.      different things depending on the details of the insn.
  818.  
  819.      Most of the arguments listed in the backtrace are useless because
  820.      they are pointers to RTL list structure.  The numeric values of the
  821.      pointers, which the debugger prints in the backtrace, have no
  822.      significance whatever; all that matters is the contents of the
  823.      objects they point to (and most of the contents are other such
  824.      pointers).
  825.  
  826.      In addition, most compiler passes consist of one or more loops that
  827.      scan the RTL insn sequence.  The most vital piece of information
  828.      about such a loop--which insn it has reached--is usually in a
  829.      local variable, not in an argument.
  830.  
  831.      What you need to provide in addition to a backtrace are the values
  832.      of the local variables for several stack frames up.  When a local
  833.      variable or an argument is an RTX, first print its value and then
  834.      use the GDB command `pr' to print the RTL expression that it points
  835.      to.  (If GDB doesn't run on your machine, use your debugger to call
  836.      the function `debug_rtx' with the RTX as an argument.)  In
  837.      general, whenever a variable is a pointer, its value is no use
  838.      without the data it points to.
  839.  
  840.    Here are some things that are not necessary:
  841.  
  842.    * A description of the envelope of the bug.
  843.  
  844.      Often people who encounter a bug spend a lot of time investigating
  845.      which changes to the input file will make the bug go away and which
  846.      changes will not affect it.
  847.  
  848.      This is often time consuming and not very useful, because the way
  849.      we will find the bug is by running a single example under the
  850.      debugger with breakpoints, not by pure deduction from a series of
  851.      examples.  You might as well save your time for something else.
  852.  
  853.      Of course, if you can find a simpler example to report *instead* of
  854.      the original one, that is a convenience.  Errors in the output
  855.      will be easier to spot, running under the debugger will take less
  856.      time, etc.  Most GNU CC bugs involve just one function, so the
  857.      most straightforward way to simplify an example is to delete all
  858.      the function definitions except the one where the bug occurs.
  859.      Those earlier in the file may be replaced by external declarations
  860.      if the crucial function depends on them.  (Exception: inline
  861.      functions may affect compilation of functions defined later in the
  862.      file.)
  863.  
  864.      However, simplification is not vital; if you don't want to do this,
  865.      report the bug anyway and send the entire test case you used.
  866.  
  867.    * In particular, some people insert conditionals `#ifdef BUG' around
  868.      a statement which, if removed, makes the bug not happen.  These
  869.      are just clutter; we won't pay any attention to them anyway.
  870.      Besides, you should send us cpp output, and that can't have
  871.      conditionals.
  872.  
  873.    * A patch for the bug.
  874.  
  875.      A patch for the bug is useful if it is a good one.  But don't omit
  876.      the necessary information, such as the test case, on the
  877.      assumption that a patch is all we need.  We might see problems
  878.      with your patch and decide to fix the problem another way, or we
  879.      might not understand it at all.
  880.  
  881.      Sometimes with a program as complicated as GNU CC it is very hard
  882.      to construct an example that will make the program follow a
  883.      certain path through the code.  If you don't send the example, we
  884.      won't be able to construct one, so we won't be able to verify that
  885.      the bug is fixed.
  886.  
  887.      And if we can't understand what bug you are trying to fix, or why
  888.      your patch should be an improvement, we won't install it.  A test
  889.      case will help us to understand.
  890.  
  891.      *Note Sending Patches::, for guidelines on how to make it easy for
  892.      us to understand and install your patches.
  893.  
  894.    * A guess about what the bug is or what it depends on.
  895.  
  896.      Such guesses are usually wrong.  Even I can't guess right about
  897.      such things without first using the debugger to find the facts.
  898.  
  899.    * A core dump file.
  900.  
  901.      We have no way of examining a core dump for your type of machine
  902.      unless we have an identical system--and if we do have one, we
  903.      should be able to reproduce the crash ourselves.
  904.  
  905. 
  906. File: gcc.info,  Node: Sending Patches,  Prev: Bug Reporting,  Up: Bugs
  907.  
  908. Sending Patches for GNU CC
  909. ==========================
  910.  
  911.    If you would like to write bug fixes or improvements for the GNU C
  912. compiler, that is very helpful.  When you send your changes, please
  913. follow these guidelines to avoid causing extra work for us in studying
  914. the patches.
  915.  
  916.    If you don't follow these guidelines, your information might still be
  917. useful, but using it will take extra work.  Maintaining GNU C is a lot
  918. of work in the best of circumstances, and we can't keep up unless you do
  919. your best to help.
  920.  
  921.    * Send an explanation with your changes of what problem they fix or
  922.      what improvement they bring about.  For a bug fix, just include a
  923.      copy of the bug report, and explain why the change fixes the bug.
  924.  
  925.      (Referring to a bug report is not as good as including it, because
  926.      then we will have to look it up, and we have probably already
  927.      deleted it if we've already fixed the bug.)
  928.  
  929.    * Always include a proper bug report for the problem you think you
  930.      have fixed.  We need to convince ourselves that the change is
  931.      right before installing it.  Even if it is right, we might have
  932.      trouble judging it if we don't have a way to reproduce the problem.
  933.  
  934.    * Include all the comments that are appropriate to help people
  935.      reading the source in the future understand why this change was
  936.      needed.
  937.  
  938.    * Don't mix together changes made for different reasons.  Send them
  939.      *individually*.
  940.  
  941.      If you make two changes for separate reasons, then we might not
  942.      want to install them both.  We might want to install just one.  If
  943.      you send them all jumbled together in a single set of diffs, we
  944.      have to do extra work to disentangle them--to figure out which
  945.      parts of the change serve which purpose.  If we don't have time
  946.      for this, we might have to ignore your changes entirely.
  947.  
  948.      If you send each change as soon as you have written it, with its
  949.      own explanation, then the two changes never get tangled up, and we
  950.      can consider each one properly without any extra work to
  951.      disentangle them.
  952.  
  953.      Ideally, each change you send should be impossible to subdivide
  954.      into parts that we might want to consider separately, because each
  955.      of its parts gets its motivation from the other parts.
  956.  
  957.    * Send each change as soon as that change is finished.  Sometimes
  958.      people think they are helping us by accumulating many changes to
  959.      send them all together.  As explained above, this is absolutely
  960.      the worst thing you could do.
  961.  
  962.      Since you should send each change separately, you might as well
  963.      send it right away.  That gives us the option of installing it
  964.      immediately if it is important.
  965.  
  966.    * Use `diff -c' to make your diffs.  Diffs without context are hard
  967.      for us to install reliably.  More than that, they make it hard for
  968.      us to study the diffs to decide whether we want to install them.
  969.      Unidiff format is better than contextless diffs, but not as easy
  970.      to read as `-c' format.
  971.  
  972.      If you have GNU diff, use `diff -cp', which shows the name of the
  973.      function that each change occurs in.
  974.  
  975.    * Write the change log entries for your changes.  We get lots of
  976.      changes, and we don't have time to do all the change log writing
  977.      ourselves.
  978.  
  979.      Read the `ChangeLog' file to see what sorts of information to put
  980.      in, and to learn the style that we use.  The purpose of the change
  981.      log is to show people where to find what was changed.  So you need
  982.      to be specific about what functions you changed; in large
  983.      functions, it's often helpful to indicate where within the
  984.      function the change was.
  985.  
  986.      On the other hand, once you have shown people where to find the
  987.      change, you need not explain its purpose.  Thus, if you add a new
  988.      function, all you need to say about it is that it is new.  If you
  989.      feel that the purpose needs explaining, it probably does--but the
  990.      explanation will be much more useful if you put it in comments in
  991.      the code.
  992.  
  993.      If you would like your name to appear in the header line for who
  994.      made the change, send us the header line.
  995.  
  996.    * When you write the fix, keep in mind that we can't install a
  997.      change that would break other systems.
  998.  
  999.      People often suggest fixing a problem by changing
  1000.      machine-independent files such as `toplev.c' to do something
  1001.      special that a particular system needs.  Sometimes it is totally
  1002.      obvious that such changes would break GNU CC for almost all users.
  1003.      We can't possibly make a change like that.  At best it might tell
  1004.      us how to write another patch that would solve the problem
  1005.      acceptably.
  1006.  
  1007.      Sometimes people send fixes that *might* be an improvement in
  1008.      general--but it is hard to be sure of this.  It's hard to install
  1009.      such changes because we have to study them very carefully.  Of
  1010.      course, a good explanation of the reasoning by which you concluded
  1011.      the change was correct can help convince us.
  1012.  
  1013.      The safest changes are changes to the configuration files for a
  1014.      particular machine.  These are safe because they can't create new
  1015.      bugs on other machines.
  1016.  
  1017.      Please help us keep up with the workload by designing the patch in
  1018.      a form that is good to install.
  1019.  
  1020. 
  1021. File: gcc.info,  Node: Service,  Next: VMS,  Prev: Bugs,  Up: Top
  1022.  
  1023. How To Get Help with GNU CC
  1024. ***************************
  1025.  
  1026.    If you need help installing, using or changing GNU CC, there are two
  1027. ways to find it:
  1028.  
  1029.    * Send a message to a suitable network mailing list.  First try
  1030.      `bug-gcc@prep.ai.mit.edu', and if that brings no response, try
  1031.      `help-gcc@prep.ai.mit.edu'.
  1032.  
  1033.    * Look in the service directory for someone who might help you for a
  1034.      fee.  The service directory is found in the file named `SERVICE'
  1035.      in the GNU CC distribution.
  1036.  
  1037. 
  1038. File: gcc.info,  Node: VMS,  Next: Portability,  Prev: Service,  Up: Top
  1039.  
  1040. Using GNU CC on VMS
  1041. *******************
  1042.  
  1043. * Menu:
  1044.  
  1045. * Include Files and VMS::  Where the preprocessor looks for the include files.
  1046. * Global Declarations::    How to do globaldef, globalref and globalvalue with
  1047.                            GNU CC.
  1048. * VMS Misc::           Misc information.
  1049.  
  1050.