home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / info / gcc.i07 < prev    next >
Encoding:
GNU Info File  |  1993-06-12  |  50.3 KB  |  1,121 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.47 from the input
  2. file gcc.tex.
  3.  
  4.    This file documents the use and the internals of the GNU compiler.
  5.  
  6.    Copyright (C) 1988, 1989, 1992 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: Interoperation,  Next: Incompatibilities,  Prev: Cross-Compiler Problems,  Up: Trouble
  29.  
  30. Interoperation
  31. ==============
  32.  
  33.    This section lists various difficulties encountered in using GNU C or
  34. GNU C++ together with other compilers or with the assemblers, linkers,
  35. libraries and debuggers on certain systems.
  36.  
  37.    * GNU C normally compiles functions to return small structures and
  38.      unions in registers.  Most other compilers arrange to return them
  39.      just like larger structures and unions.  This can lead to trouble
  40.      when you link together code compiled by different compilers. To
  41.      avoid the problem, you can use the option `-fpcc-struct-return'
  42.      when compiling with GNU CC.
  43.  
  44.    * GNU C++ does not do name mangling in the same way as other C++
  45.      compilers.  This means that object files compiled with one compiler
  46.      cannot be used with another.
  47.  
  48.      GNU C++ also uses different techniques for arranging virtual
  49.      function tables and the layout of class instances.  In general,
  50.      therefore, linking code compiled with different C++ compilers does
  51.      not work.
  52.  
  53.    * Older GDB versions sometimes fail to read the output of GNU CC
  54.      version 2.  If you have trouble, get GDB version 4.4 or later.
  55.  
  56.    * DBX rejects some files produced by GNU CC, though it accepts
  57.      similar constructs in output from PCC.  Until someone can supply a
  58.      coherent description of what is valid DBX input and what is not,
  59.      there is nothing I can do about these problems.  You are on your
  60.      own.
  61.  
  62.    * The GNU assembler (GAS) does not support PIC.  To generate PIC
  63.      code, you must use some other assembler, such as `/bin/as'.
  64.  
  65.    * On some BSD systems including some versions of Ultrix, use of
  66.      profiling causes static variable destructors (currently used only
  67.      in C++) not to be run.
  68.  
  69.    * Use of `-I/usr/include' may cause trouble.
  70.  
  71.      Many systems come with header files that won't work with GNU CC
  72.      unless corrected by `fixincludes'.  The corrected header files go
  73.      in a new directory; GNU CC searches this directory before
  74.      `/usr/include'. If you use `-I/usr/include', this tells GNU CC to
  75.      search `/usr/include' earlier on, before the corrected headers. 
  76.      The result is that you get the uncorrected header files.
  77.  
  78.      Instead, you should use these options:
  79.  
  80.           -I/usr/local/lib/gcc-lib/TARGET/VERSION/include -I/usr/include
  81.  
  82.    * On a Sparc, GNU CC aligns all values of type `double' on an 8-byte
  83.      boundary, and it expects every `double' to be so aligned.  The Sun
  84.      compiler usually gives `double' values 8-byte alignment, with one
  85.      exception: function arguments of type `double' may not be aligned.
  86.  
  87.      As a result, if a function compiled with Sun CC takes the address
  88.      of an argument of type `double' and passes this pointer of type
  89.      `double *' to a function compiled with GNU CC, dereferencing the
  90.      pointer may cause a fatal signal.
  91.  
  92.      One way to solve this problem is to compile your entire program
  93.      with GNU CC.  Another solution is to modify the function that is
  94.      compiled with Sun CC to copy the argument into a local variable;
  95.      local variables are always properly aligned.  A third solution is
  96.      to modify the function that uses the pointer to dereference it via
  97.      the following function `access_double' instead of directly with
  98.      `*':
  99.  
  100.           inline double
  101.           access_double (double *unaligned_ptr)
  102.           {
  103.             union d2i { double d; int i[2]; };
  104.           
  105.             union d2i *p = (union d2i *) unaligned_ptr;
  106.             union d2i u;
  107.           
  108.             u.i[0] = p->i[0];
  109.             u.i[1] = p->i[1];
  110.           
  111.             return u.d;
  112.           }
  113.  
  114.      Storing into the pointer can be done likewise with the same union.
  115.  
  116.    * On a Sun, linking using GNU CC fails to find a shared library and
  117.      reports that the library doesn't exist at all.
  118.  
  119.      This happens if you are using the GNU linker, because it does only
  120.      static linking and looks only for unshared libraries.  If you have
  121.      a shared library with no unshared counterpart, the GNU linker
  122.      won't find anything.
  123.  
  124.      We hope to make a linker which supports Sun shared libraries, but
  125.      please don't ask when it will be finished--we don't know.
  126.  
  127.    * Sun forgot to include a static version of `libdl.a' with some
  128.      versions of SunOS (mainly 4.1).  This results in undefined symbols
  129.      when linking static binaries (that is, if you use `-static').  If
  130.      you see undefined symbols `_dlclose', `_dlsym' or `_dlopen' when
  131.      linking, compile and link against the file `mit/util/misc/dlsym.c'
  132.      from the MIT version of X windows.
  133.  
  134.    * On the HP PA machine, ADB sometimes fails to work on functions
  135.      compiled with GNU CC.  Specifically, it fails to work on functions
  136.      that use `alloca' or variable-size arrays.  This is because GNU CC
  137.      doesn't generate HP-UX unwind descriptors for such functions.  It
  138.      may even be impossible to generate them.
  139.  
  140.    * Profiling is not supported on the HP PA machine.  Neither is
  141.      debugging (`-g'), unless you use the preliminary GNU tools (*note
  142.      Installation::.).
  143.  
  144.    * GNU CC on the HP PA handles variadic function arguments using a
  145.      calling convention incompatible with the HP compiler.  This is
  146.      only a problem for routines that take `va_list' as parameters,
  147.      such as `vprintf'.  This may be fixed eventually.
  148.  
  149.    * The HP-UX linker has a bug which can cause programs which make use
  150.      of `const' variables to fail in unusual ways.  If your program
  151.      makes use of global `const' variables, we suggest you compile with
  152.      the following additional options:
  153.  
  154.           -Dconst="" -D__const="" -D__const__="" -fwritable-strings
  155.  
  156.      This will force the `const' variables into the DATA subspace which
  157.      will avoid the linker bug.
  158.  
  159.      Another option one might use to work around this problem is
  160.      `-mkernel'.  `-mkernel' changes how the address of variables is
  161.      computed to a sequence less likely to tickle the HP-UX linker bug.
  162.  
  163.      We hope to work around this problem in GNU CC 2.4, if HP does not
  164.      fix it.
  165.  
  166.    * Taking the address of a label may generate errors from the HP-UX
  167.      PA assembler.  GAS for the PA does not have this problem.
  168.  
  169.    * The current version of the assembler (`/bin/as') for the RS/6000
  170.      has certain problems that prevent the `-g' option in GCC from
  171.      working.
  172.  
  173.      IBM has produced a fixed version of the assembler.  The replacement
  174.      assembler is not a standard component of either AIX 3.1.5 or AIX
  175.      3.2, but is expected to become standard in a future distribution. 
  176.      This assembler is available from IBM as APAR IX22829.  Yet more
  177.      bugs have been fixed in a newer assembler, which will shortly be
  178.      available as APAR IX26107.  See the file `README.RS6000' for more
  179.      details on these assemblers.
  180.  
  181.    * On the IBM RS/6000, compiling code of the form
  182.  
  183.           extern int foo;
  184.           
  185.           ... foo ...
  186.           
  187.           static int foo;
  188.  
  189.      will cause the linker to report an undefined symbol `foo'.
  190.      Although this behavior differs from most other systems, it is not a
  191.      bug because redefining an `extern' variable as `static' is
  192.      undefined in ANSI C.
  193.  
  194.    * On VMS, GAS versions 1.38.1 and earlier may cause spurious warning
  195.      messages from the linker.  These warning messages complain of
  196.      mismatched psect attributes.  You can ignore them.  *Note VMS
  197.      Install::.
  198.  
  199.    * On NewsOS version 3, if you include both `stddef.h' and
  200.      `sys/types.h', you get an error because there are two typedefs of
  201.      `size_t'.  You should change `sys/types.h' by adding these lines
  202.      around the definition of `size_t':
  203.  
  204.           #ifndef _SIZE_T
  205.           #define _SIZE_T
  206.           ACTUAL TYPEDEF HERE
  207.           #endif
  208.  
  209.    * On the Alliant, the system's own convention for returning
  210.      structures and unions is unusual, and is not compatible with GNU
  211.      CC no matter what options are used.
  212.  
  213.    * On the IBM RT PC, the MetaWare HighC compiler (hc) uses yet another
  214.      convention for structure and union returning.  Use
  215.      `-mhc-struct-return' to tell GNU CC to use a convention compatible
  216.      with it.
  217.  
  218.    * On Ultrix, the Fortran compiler expects registers 2 through 5 to
  219.      be saved by function calls.  However, the C compiler uses
  220.      conventions compatible with BSD Unix: registers 2 through 5 may be
  221.      clobbered by function calls.
  222.  
  223.      GNU CC uses the same convention as the Ultrix C compiler.  You can
  224.      use these options to produce code compatible with the Fortran
  225.      compiler:
  226.  
  227.           -fcall-saved-r2 -fcall-saved-r3 -fcall-saved-r4 -fcall-saved-r5
  228.  
  229.    * On the WE32k, you may find that programs compiled with GNU CC do
  230.      not work with the standard shared C ilbrary.  You may need to link
  231.      with the ordinary C compiler.  If you do so, you must specify the
  232.      following options:
  233.  
  234.           -L/usr/local/lib/gcc-lib/we32k-att-sysv/2.3 -lgcc -lc_s
  235.  
  236.      The first specifies where to find the library `libgcc.a' specified
  237.      with the `-lgcc' option.
  238.  
  239.      GNU CC does linking by invoking `ld', just as `cc' does, and there
  240.      is no reason why it *should* matter which compilation program you
  241.      use to invoke `ld'.  If someone tracks this problem down, it can
  242.      probably be fixed easily.
  243.  
  244. 
  245. File: gcc.info,  Node: Incompatibilities,  Next: Disappointments,  Prev: Interoperation,  Up: Trouble
  246.  
  247. Incompatibilities of GNU CC
  248. ===========================
  249.  
  250.    There are several noteworthy incompatibilities between GNU C and most
  251. existing (non-ANSI) versions of C.  The `-traditional' option
  252. eliminates many of these incompatibilities, *but not all*, by telling
  253. GNU C to behave like the other C compilers.
  254.  
  255.    * GNU CC normally makes string constants read-only.  If several
  256.      identical-looking string constants are used, GNU CC stores only one
  257.      copy of the string.
  258.  
  259.      One consequence is that you cannot call `mktemp' with a string
  260.      constant argument.  The function `mktemp' always alters the string
  261.      its argument points to.
  262.  
  263.      Another consequence is that `sscanf' does not work on some systems
  264.      when passed a string constant as its format control string or
  265.      input. This is because `sscanf' incorrectly tries to write into
  266.      the string constant.  Likewise `fscanf' and `scanf'.
  267.  
  268.      The best solution to these problems is to change the program to use
  269.      `char'-array variables with initialization strings for these
  270.      purposes instead of string constants.  But if this is not possible,
  271.      you can use the `-fwritable-strings' flag, which directs GNU CC to
  272.      handle string constants the same way most C compilers do.
  273.      `-traditional' also has this effect, among others.
  274.  
  275.    * `-2147483648' is positive.
  276.  
  277.      This is because 2147483648 cannot fit in the type `int', so
  278.      (following the ANSI C rules) its data type is `unsigned long int'.
  279.      Negating this value yields 2147483648 again.
  280.  
  281.    * GNU CC does not substitute macro arguments when they appear inside
  282.      of string constants.  For example, the following macro in GNU CC
  283.  
  284.           #define foo(a) "a"
  285.  
  286.      will produce output `"a"' regardless of what the argument A is.
  287.  
  288.      The `-traditional' option directs GNU CC to handle such cases
  289.      (among others) in the old-fashioned (non-ANSI) fashion.
  290.  
  291.    * When you use `setjmp' and `longjmp', the only automatic variables
  292.      guaranteed to remain valid are those declared `volatile'.  This is
  293.      a consequence of automatic register allocation.  Consider this
  294.      function:
  295.  
  296.           jmp_buf j;
  297.           
  298.           foo ()
  299.           {
  300.             int a, b;
  301.           
  302.             a = fun1 ();
  303.             if (setjmp (j))
  304.               return a;
  305.           
  306.             a = fun2 ();
  307.             /* `longjmp (j)' may occur in `fun3'. */
  308.             return a + fun3 ();
  309.           }
  310.  
  311.      Here `a' may or may not be restored to its first value when the
  312.      `longjmp' occurs.  If `a' is allocated in a register, then its
  313.      first value is restored; otherwise, it keeps the last value stored
  314.      in it.
  315.  
  316.      If you use the `-W' option with the `-O' option, you will get a
  317.      warning when GNU CC thinks such a problem might be possible.
  318.  
  319.      The `-traditional' option directs GNU C to put variables in the
  320.      stack by default, rather than in registers, in functions that call
  321.      `setjmp'.  This results in the behavior found in traditional C
  322.      compilers.
  323.  
  324.    * Programs that use preprocessor directives in the middle of macro
  325.      arguments do not work with GNU CC.  For example, a program like
  326.      this will not work:
  327.  
  328.           foobar (
  329.           #define luser
  330.                   hack)
  331.  
  332.      ANSI C does not permit such a construct.  It would make sense to
  333.      support it when `-traditional' is used, but it is too much work to
  334.      implement.
  335.  
  336.    * Declarations of external variables and functions within a block
  337.      apply only to the block containing the declaration.  In other
  338.      words, they have the same scope as any other declaration in the
  339.      same place.
  340.  
  341.      In some other C compilers, a `extern' declaration affects all the
  342.      rest of the file even if it happens within a block.
  343.  
  344.      The `-traditional' option directs GNU C to treat all `extern'
  345.      declarations as global, like traditional compilers.
  346.  
  347.    * In traditional C, you can combine `long', etc., with a typedef
  348.      name, as shown here:
  349.  
  350.           typedef int foo;
  351.           typedef long foo bar;
  352.  
  353.      In ANSI C, this is not allowed: `long' and other type modifiers
  354.      require an explicit `int'.  Because this criterion is expressed by
  355.      Bison grammar rules rather than C code, the `-traditional' flag
  356.      cannot alter it.
  357.  
  358.    * PCC allows typedef names to be used as function parameters.  The
  359.      difficulty described immediately above applies here too.
  360.  
  361.    * PCC allows whitespace in the middle of compound assignment
  362.      operators such as `+='.  GNU CC, following the ANSI standard, does
  363.      not allow this.  The difficulty described immediately above
  364.      applies here too.
  365.  
  366.    * GNU CC complains about unterminated character constants inside of
  367.      preprocessor conditionals that fail.  Some programs have English
  368.      comments enclosed in conditionals that are guaranteed to fail; if
  369.      these comments contain apostrophes, GNU CC will probably report an
  370.      error.  For example, this code would produce an error:
  371.  
  372.           #if 0
  373.           You can't expect this to work.
  374.           #endif
  375.  
  376.      The best solution to such a problem is to put the text into an
  377.      actual C comment delimited by `/*...*/'.  However, `-traditional'
  378.      suppresses these error messages.
  379.  
  380.    * Many user programs contain the declaration `long time ();'.  In the
  381.      past, the system header files on many systems did not actually
  382.      declare `time', so it did not matter what type your program
  383.      declared it to return.  But in systems with ANSI C headers, `time'
  384.      is declared to return `time_t', and if that is not the same as
  385.      `long', then `long time ();' is erroneous.
  386.  
  387.      The solution is to change your program to use `time_t' as the
  388.      return type of `time'.
  389.  
  390.    * When compiling functions that return `float', PCC converts it to a
  391.      double.  GNU CC actually returns a `float'.  If you are concerned
  392.      with PCC compatibility, you should declare your functions to return
  393.      `double'; you might as well say what you mean.
  394.  
  395.    * When compiling functions that return structures or unions, GNU CC
  396.      output code normally uses a method different from that used on most
  397.      versions of Unix.  As a result, code compiled with GNU CC cannot
  398.      call a structure-returning function compiled with PCC, and vice
  399.      versa.
  400.  
  401.      The method used by GNU CC is as follows: a structure or union
  402.      which is 1, 2, 4 or 8 bytes long is returned like a scalar.  A
  403.      structure or union with any other size is stored into an address
  404.      supplied by the caller (usually in a special, fixed register, but
  405.      on some machines it is passed on the stack).  The
  406.      machine-description macros `STRUCT_VALUE' and
  407.      `STRUCT_INCOMING_VALUE' tell GNU CC where to pass this address.
  408.  
  409.      By contrast, PCC on most target machines returns structures and
  410.      unions of any size by copying the data into an area of static
  411.      storage, and then returning the address of that storage as if it
  412.      were a pointer value. The caller must copy the data from that
  413.      memory area to the place where the value is wanted.  GNU CC does
  414.      not use this method because it is slower and nonreentrant.
  415.  
  416.      On some newer machines, PCC uses a reentrant convention for all
  417.      structure and union returning.  GNU CC on most of these machines
  418.      uses a compatible convention when returning structures and unions
  419.      in memory, but still returns small structures and unions in
  420.      registers.
  421.  
  422.      You can tell GNU CC to use a compatible convention for all
  423.      structure and union returning with the option
  424.      `-fpcc-struct-return'.
  425.  
  426. 
  427. File: gcc.info,  Node: Disappointments,  Next: Protoize Caveats,  Prev: Incompatibilities,  Up: Trouble
  428.  
  429. Disappointments and Misunderstandings
  430. =====================================
  431.  
  432.    These problems are perhaps regrettable, but we don't know any
  433. practical way around them.
  434.  
  435.    * Certain local variables aren't recognized by debuggers when you
  436.      compile with optimization.
  437.  
  438.      This occurs because sometimes GNU CC optimizes the variable out of
  439.      existence.  There is no way to tell the debugger how to compute the
  440.      value such a variable "would have had", and it is not clear that
  441.      would be desirable anyway.  So GNU CC simply does not mention the
  442.      eliminated variable when it writes debugging information.
  443.  
  444.      You have to expect a certain amount of disagreement between the
  445.      executable and your source code, when you use optimization.
  446.  
  447.    * Users often think it is a bug when GNU CC reports an error for code
  448.      like this:
  449.  
  450.           int foo (struct mumble *);
  451.           
  452.           struct mumble { ... };
  453.           
  454.           int foo (struct mumble *x)
  455.           { ... }
  456.  
  457.      This code really is erroneous, because the scope of `struct
  458.      mumble' in the prototype is limited to the argument list
  459.      containing it. It does not refer to the `struct mumble' defined
  460.      with file scope immediately below--they are two unrelated types
  461.      with similar names in different scopes.
  462.  
  463.      But in the definition of `foo', the file-scope type is used
  464.      because that is available to be inherited.  Thus, the definition
  465.      and the prototype do not match, and you get an error.
  466.  
  467.      This behavior may seem silly, but it's what the ANSI standard
  468.      specifies. It is easy enough for you to make your code work by
  469.      moving the definition of `struct mumble' above the prototype. 
  470.      It's not worth being incompatible with ANSI C just to avoid an
  471.      error for the example shown above.
  472.  
  473.    * Accesses to bitfields even in volatile objects works by accessing
  474.      larger objects, such as a byte or a word.  You cannot rely on what
  475.      size of object is accessed in order to read or write the bitfield;
  476.      it may even vary for a given bitfield according to the precise
  477.      usage.
  478.  
  479.      If you care about controlling the amount of memory that is
  480.      accessed, use volatile but do not use bitfields.
  481.  
  482.    * On 68000 systems, you can get paradoxical results if you test the
  483.      precise values of floating point numbers.  For example, you can
  484.      find that a floating point value which is not a NaN is not equal
  485.      to itself. This results from the fact that the the floating point
  486.      registers hold a few more bits of precision than fit in a `double'
  487.      in memory. Compiled code moves values between memory and floating
  488.      point registers at its convenience, and moving them into memory
  489.      truncates them.
  490.  
  491.      You can partially avoid this problem by using the option
  492.      `-ffloat-store' (*note Optimize Options::.).
  493.  
  494.    * On the MIPS, variable argument functions using `varargs.h' cannot
  495.      have a floating point value for the first argument.  The reason
  496.      for this is that in the absence of a prototype in scope, if the
  497.      first argument is a floating point, it is passed in a floating
  498.      point register, rather than an integer resgister.
  499.  
  500.      If the code is rewritten to use the ANSI standard `stdarg.h'
  501.      method of variable arguments, and the prototype is in scope at the
  502.      time of the call, everything will work fine.
  503.  
  504. 
  505. File: gcc.info,  Node: Protoize Caveats,  Next: Non-bugs,  Prev: Disappointments,  Up: Trouble
  506.  
  507. Caveats of using `protoize'
  508. ===========================
  509.  
  510.    The conversion programs `protoize' and `unprotoize' can sometimes
  511. change a source file in a way that won't work unless you rearrange it.
  512.  
  513.    * `protoize' can insert references to a type name or type tag before
  514.      the definition, or in a file where they are not defined.
  515.  
  516.      If this happens, compiler error messages should show you where the
  517.      new references are, so fixing the file by hand is straightforward.
  518.  
  519.    * There are some C constructs which `protoize' cannot figure out.
  520.      For example, it can't determine argument types for declaring a
  521.      pointer-to-function variable; this you must do by hand.  `protoize'
  522.      inserts a comment containing `???' each time it finds such a
  523.      variable; so you can find all such variables by searching for this
  524.      string.  ANSI C does not require declaring the argument types of
  525.      pointer-to-function types.
  526.  
  527.    * Using `unprotoize' can easily introduce bugs.  If the program
  528.      relied on prototypes to bring about conversion of arguments, these
  529.      conversions will not take place in the program without prototypes.
  530.      One case in which you can be sure `unprotoize' is safe is when you
  531.      are removing prototypes that were made with `protoize'; if the
  532.      program worked before without any prototypes, it will work again
  533.      without them.
  534.  
  535.      You can find all the places where this problem might occur by
  536.      compiling the program with the `-Wconversion' option.  It prints a
  537.      warning whenever an argument is converted.
  538.  
  539.    * Both conversion programs can be confused if there are macro calls
  540.      in and around the text to be converted.  In other words, the
  541.      standard syntax for a declaration or definition must not result
  542.      from expanding a macro. This problem is inherent in the design of
  543.      C and cannot be fixed.  If only a few functions have confusing
  544.      macro calls, you can easily convert them manually.
  545.  
  546.    * `protoize' cannot get the argument types for a function whose
  547.      definition was not actually compiled due to preprocessor
  548.      conditionals. When this happens, `protoize' changes nothing in
  549.      regard to such a function.  `protoize' tries to detect such
  550.      instances and warn about them.
  551.  
  552.      You can generally work around this problem by using `protoize' step
  553.      by step, each time specifying a different set of `-D' options for
  554.      compilation, until all of the functions have been converted. 
  555.      There is no automatic way to verify that you have got them all,
  556.      however.
  557.  
  558.    * Confusion may result if there is an occasion to convert a function
  559.      declaration or definition in a region of source code where there
  560.      is more than one formal parameter list present.  Thus, attempts to
  561.      convert code containing multiple (conditionally compiled) versions
  562.      of a single function header (in the same vicinity) may not produce
  563.      the desired (or expected) results.
  564.  
  565.      If you plan on converting source files which contain such code, it
  566.      is recommended that you first make sure that each conditionally
  567.      compiled region of source code which contains an alternative
  568.      function header also contains at least one additional follower
  569.      token (past the final right parenthesis of the function header). 
  570.      This should circumvent the problem.
  571.  
  572.    * `unprotoize' can become confused when trying to convert a function
  573.      definition or declaration which contains a declaration for a
  574.      pointer-to-function formal argument which has the same name as the
  575.      function being defined or declared.  We recommand you avoid such
  576.      choices of formal parameter names.
  577.  
  578.    * You might also want to correct some of the indentation by hand and
  579.      break long lines.  (The conversion programs don't write lines
  580.      longer than eighty characters in any case.)
  581.  
  582. 
  583. File: gcc.info,  Node: Non-bugs,  Prev: Protoize Caveats,  Up: Trouble
  584.  
  585. Certain Changes We Don't Want to Make
  586. =====================================
  587.  
  588.    This section lists changes that people frequently request, but which
  589. we do not make because we think GNU CC is better without them.
  590.  
  591.    * Checking the number and type of arguments to a function which has
  592.      an old-fashioned definition and no prototype.
  593.  
  594.      Such a feature would work only occasionally--only for calls that
  595.      appear in the same file as the called function, following the
  596.      definition.  The only way to check all calls reliably is to add a
  597.      prototype for the function.  But adding a prototype eliminates the
  598.      motivation for this feature.  So the feature is not worthwhile.
  599.  
  600.    * Warning about using an expression whose type is signed as a shift
  601.      count.
  602.  
  603.      Shift count operands are probably signed more often than unsigned.
  604.      Warning about this would cause far more annoyance than good.
  605.  
  606.    * Warning about assigning a signed value to an unsigned variable.
  607.  
  608.      Such assignments must be very common; warning about them would
  609.      cause more annoyance than good.
  610.  
  611.    * Warning about unreachable code.
  612.  
  613.      It's very common to have unreachable code in machine-generated
  614.      programs.  For example, this happens normally in some files of GNU
  615.      C itself.
  616.  
  617.    * Warning when a non-void function value is ignored.
  618.  
  619.      Coming as I do from a Lisp background, I balk at the idea that
  620.      there is something dangerous about discarding a value.  There are
  621.      functions that return values which some callers may find useful;
  622.      it makes no sense to clutter the program with a cast to `void'
  623.      whenever the value isn't useful.
  624.  
  625.    * Assuming (for optimization) that the address of an external symbol
  626.      is never zero.
  627.  
  628.      This assumption is false on certain systems when `#pragma weak' is
  629.      used.
  630.  
  631.    * Making `-fshort-enums' the default.
  632.  
  633.      This would cause storage layout to be incompatible with most other
  634.      C compilers.  And it doesn't seem very important, given that you
  635.      can get the same result in other ways.  The case where it matters
  636.      most is when the enumeration-valued object is inside a structure,
  637.      and in that case you can specify a field width explicitly.
  638.  
  639.    * Making bitfields unsigned by default on particular machines where
  640.      "the ABI standard" says to do so.
  641.  
  642.      The ANSI C standard leaves it up to the implementation whether a
  643.      bitfield declared plain `int' is signed or not.  This in effect
  644.      creates two alternative dialects of C.
  645.  
  646.      The GNU C compiler supports both dialects; you can specify the
  647.      dialect you want with the option `-fsigned-bitfields' or
  648.      `-funsigned-bitfields'.  However, this leaves open the question of
  649.      which dialect to use by default.
  650.  
  651.      Currently, the preferred dialect makes plain bitfields signed,
  652.      because this is simplest.  Since `int' is the same as `signed int'
  653.      in every other context, it is cleanest for them to be the same in
  654.      bitfields as well.
  655.  
  656.      Some computer manufacturers have published Application Binary
  657.      Interface standards which specify that plain bitfields should be
  658.      unsigned.  It is a mistake, however, to say anything about this
  659.      issue in an ABI.  This is because the handling of plain bitfields
  660.      distinguishes two dialects of C. Both dialects are meaningful on
  661.      every type of machine.  Whether a particular object file was
  662.      compiled using signed bitfields or unsigned is of no concern to
  663.      other object files, even if they access the same bitfields in the
  664.      same data structures.
  665.  
  666.      A given program is written in one or the other of these two
  667.      dialects. The program stands a chance to work on most any machine
  668.      if it is compiled with the proper dialect.  It is unlikely to work
  669.      at all if compiled with the wrong dialect.
  670.  
  671.      Many users appreciate the GNU C compiler because it provides an
  672.      environment that is uniform across machines.  These users would be
  673.      inconvenienced if the compiler treated plain bitfields differently
  674.      on certain machines.
  675.  
  676.      Occasionally users write programs intended only for a particular
  677.      machine type.  On these occasions, the users would benefit if the
  678.      GNU C compiler were to support by default the same dialect as the
  679.      other compilers on that machine.  But such applications are rare. 
  680.      And users writing a program to run on more than one type of
  681.      machine cannot possibly benefit from this kind of compatibility.
  682.  
  683.      This is why GNU CC does and will treat plain bitfields in the same
  684.      fashion on all types of machines (by default).
  685.  
  686.      There are some arguments for making bitfields unsigned by default
  687.      on all machines.  If, for example, this becomes a universal de
  688.      facto standard, it would make sense for GNU CC to go along with
  689.      it.  This is something to be considered in the future.
  690.  
  691.      (Of course, users strongly concerned about portability should
  692.      indicate explicitly in each bitfield whether it is signed or not. 
  693.      In this way, they write programs which have the same meaning in
  694.      both C dialects.)
  695.  
  696.    * Undefining `__STDC__' when `-ansi' is not used.
  697.  
  698.      Currently, GNU CC defines `__STDC__' as long as you don't use
  699.      `-traditional'.  This provides good results in practice.
  700.  
  701.      Programmers normally use conditionals on `__STDC__' to ask whether
  702.      it is safe to use certain features of ANSI C, such as function
  703.      prototypes or ANSI token concatenation.  Since plain `gcc' supports
  704.      all the features of ANSI C, the correct answer to these questions
  705.      is "yes".
  706.  
  707.      Some users try to use `__STDC__' to check for the availability of
  708.      certain library facilities.  This is actually incorrect usage in
  709.      an ANSI C program, because the ANSI C standard says that a
  710.      conforming freestanding implementation should define `__STDC__'
  711.      even though it does not have the library facilities.  `gcc -ansi
  712.      -pedantic' is a conforming freestanding implementation, and it is
  713.      therefore required to define `__STDC__', even though it does not
  714.      come with an ANSI C library.
  715.  
  716.      Sometimes people say that defining `__STDC__' in a compiler that
  717.      does not completely conform to the ANSI C standard somehow
  718.      violates the standard.  This is illogical.  The standard is a
  719.      standard for compilers that claim to support ANSI C, such as `gcc
  720.      -ansi'--not for other compilers such as plain `gcc'.  Whatever the
  721.      ANSI C standard says is relevant to the design of plain `gcc'
  722.      without `-ansi' only for pragmatic reasons, not as a requirement.
  723.  
  724.    * Undefining `__STDC__' in C++.
  725.  
  726.      Programs written to compile with C++-to-C translators get the
  727.      value of `__STDC__' that goes with the C compiler that is
  728.      subsequently used.  These programs must test `__STDC__' to
  729.      determine what kind of C preprocessor that compiler uses: whether
  730.      they should concatenate tokens in the ANSI C fashion or in the
  731.      traditional fashion.
  732.  
  733.      These programs work properly with GNU C++ if `__STDC__' is defined.
  734.      They would not work otherwise.
  735.  
  736.      In addition, many header files are written to provide prototypes
  737.      in ANSI C but not in traditional C.  Many of these header files
  738.      can work without change in C++ provided `__STDC__' is defined.  If
  739.      `__STDC__' is not defined, they will all fail, and will all need
  740.      to be changed to test explicitly for C++ as well.
  741.  
  742.    * Deleting "empty" loops.
  743.  
  744.      GNU CC does not delete "empty" loops because the most likely reason
  745.      you would put one in a program is to have a delay.  Deleting them
  746.      will not make real programs run any faster, so it would be
  747.      pointless.
  748.  
  749.      It would be different if optimization of a nonempty loop could
  750.      produce an empty one.  But this generally can't happen.
  751.  
  752. 
  753. File: gcc.info,  Node: Bugs,  Next: Service,  Prev: Trouble,  Up: Top
  754.  
  755. Reporting Bugs
  756. **************
  757.  
  758.    Your bug reports play an essential role in making GNU CC reliable.
  759.  
  760.    When you encounter a problem, the first thing to do is to see if it
  761. is already known.  *Note Trouble::.  If it isn't known, then you should
  762. report the problem.
  763.  
  764.    Reporting a bug may help you by bringing a solution to your problem,
  765. or it may not.  (If it does not, look in the service directory; see
  766. *Note Service::.)  In any case, the principal function of a bug report
  767. is to help the entire community by making the next version of GNU CC
  768. work better.  Bug reports are your contribution to the maintenance of
  769. GNU CC.
  770.  
  771.    In order for a bug report to serve its purpose, you must include the
  772. information that makes for fixing the bug.
  773.  
  774. * Menu:
  775.  
  776. * Criteria:  Bug Criteria.   Have you really found a bug?
  777. * Where: Bug Lists.         Where to send your bug report.
  778. * Reporting: Bug Reporting.  How to report a bug effectively.
  779. * Patches: Sending Patches.  How to send a patch for GNU CC.
  780. * Known: Trouble.            Known problems.
  781. * Help: Service.             Where to ask for help.
  782.  
  783. 
  784. File: gcc.info,  Node: Bug Criteria,  Next: Bug Lists,  Up: Bugs
  785.  
  786. Have You Found a Bug?
  787. =====================
  788.  
  789.    If you are not sure whether you have found a bug, here are some
  790. guidelines:
  791.  
  792.    * If the compiler gets a fatal signal, for any input whatever, that
  793.      is a compiler bug.  Reliable compilers never crash.
  794.  
  795.    * If the compiler produces invalid assembly code, for any input
  796.      whatever (except an `asm' statement), that is a compiler bug,
  797.      unless the compiler reports errors (not just warnings) which would
  798.      ordinarily prevent the assembler from being run.
  799.  
  800.    * If the compiler produces valid assembly code that does not
  801.      correctly execute the input source code, that is a compiler bug.
  802.  
  803.      However, you must double-check to make sure, because you may have
  804.      run into an incompatibility between GNU C and traditional C (*note
  805.      Incompatibilities::.).  These incompatibilities might be considered
  806.      bugs, but they are inescapable consequences of valuable features.
  807.  
  808.      Or you may have a program whose behavior is undefined, which
  809.      happened by chance to give the desired results with another C or
  810.      C++ compiler.
  811.  
  812.      For example, in many nonoptimizing compilers, you can write `x;'
  813.      at the end of a function instead of `return x;', with the same
  814.      results.  But the value of the function is undefined if `return'
  815.      is omitted; it is not a bug when GNU CC produces different results.
  816.  
  817.      Problems often result from expressions with two increment
  818.      operators, as in `f (*p++, *p++)'.  Your previous compiler might
  819.      have interpreted that expression the way you intended; GNU CC might
  820.      interpret it another way.  Neither compiler is wrong.  The bug is
  821.      in your code.
  822.  
  823.      After you have localized the error to a single source line, it
  824.      should be easy to check for these things.  If your program is
  825.      correct and well defined, you have found a compiler bug.
  826.  
  827.    * If the compiler produces an error message for valid input, that is
  828.      a compiler bug.
  829.  
  830.    * If the compiler does not produce an error message for invalid
  831.      input, that is a compiler bug.  However, you should note that your
  832.      idea of "invalid input" might be my idea of "an extension" or
  833.      "support for traditional practice".
  834.  
  835.    * If you are an experienced user of C or C++ compilers, your
  836.      suggestions for improvement of GNU CC or GNU C++ are welcome in
  837.      any case.
  838.  
  839. 
  840. File: gcc.info,  Node: Bug Lists,  Next: Bug Reporting,  Prev: Bug Criteria,  Up: Bugs
  841.  
  842. Where to Report Bugs
  843. ====================
  844.  
  845.    Send bug reports for GNU C to one of these addresses:
  846.  
  847.      bug-gcc@prep.ai.mit.edu
  848.      {ucbvax|mit-eddie|uunet}!prep.ai.mit.edu!bug-gcc
  849.  
  850.    Send bug reports for GNU C++ to one of these addresses:
  851.  
  852.      bug-g++@prep.ai.mit.edu
  853.      {ucbvax|mit-eddie|uunet}!prep.ai.mit.edu!bug-g++
  854.  
  855.    *Do not send bug reports to `help-gcc', or to the newsgroup
  856. `gnu.gcc.help'.*  Most users of GNU CC do not want to receive bug
  857. reports.  Those that do, have asked to be on `bug-gcc' and/or `bug-g++'.
  858.  
  859.    The mailing lists `bug-gcc' and `bug-g++' both have newsgroups which
  860. serve as repeaters: `gnu.gcc.bug' and `gnu.g++.bug'. Each mailing list
  861. and its newsgroup carry exactly the same messages.
  862.  
  863.    Often people think of posting bug reports to the newsgroup instead of
  864. mailing them.  This appears to work, but it has one problem which can be
  865. crucial: a newsgroup posting does not contain a mail path back to the
  866. sender.  Thus, if maintainers need more information, they may be unable
  867. to reach you.  For this reason, you should always send bug reports by
  868. mail to the proper mailing list.
  869.  
  870.    As a last resort, send bug reports on paper to:
  871.  
  872.      GNU Compiler Bugs
  873.      Free Software Foundation
  874.      675 Mass Ave
  875.      Cambridge, MA 02139
  876.  
  877. 
  878. File: gcc.info,  Node: Bug Reporting,  Next: Sending Patches,  Prev: Bug Lists,  Up: Bugs
  879.  
  880. How to Report Bugs
  881. ==================
  882.  
  883.    The fundamental principle of reporting bugs usefully is this:
  884. *report all the facts*.  If you are not sure whether to state a fact or
  885. leave it out, state it!
  886.  
  887.    Often people omit facts because they think they know what causes the
  888. problem and they conclude that some details don't matter.  Thus, you
  889. might assume that the name of the variable you use in an example does
  890. not matter. Well, probably it doesn't, but one cannot be sure.  Perhaps
  891. the bug is a stray memory reference which happens to fetch from the
  892. location where that name is stored in memory; perhaps, if the name were
  893. different, the contents of that location would fool the compiler into
  894. doing the right thing despite the bug.  Play it safe and give a
  895. specific, complete example.  That is the easiest thing for you to do,
  896. and the most helpful.
  897.  
  898.    Keep in mind that the purpose of a bug report is to enable someone to
  899. fix the bug if it is not known.  It isn't very important what happens if
  900. the bug is already known.  Therefore, always write your bug reports on
  901. the assumption that the bug is not known.
  902.  
  903.    Sometimes people give a few sketchy facts and ask, "Does this ring a
  904. bell?"  This cannot help us fix a bug, so it is basically useless.  We
  905. respond by asking for enough details to enable us to investigate. You
  906. might as well expedite matters by sending them to begin with.
  907.  
  908.    Try to make your bug report self-contained.  If we have to ask you
  909. for more information, it is best if you include all the previous
  910. information in your response, as well as the information that was
  911. missing.
  912.  
  913.    To enable someone to investigate the bug, you should include all
  914. these things:
  915.  
  916.    * The version of GNU CC.  You can get this by running it with the
  917.      `-v' option.
  918.  
  919.      Without this, we won't know whether there is any point in looking
  920.      for the bug in the current version of GNU CC.
  921.  
  922.    * A complete input file that will reproduce the bug.  If the bug is
  923.      in the C preprocessor, send a source file and any header files
  924.      that it requires.  If the bug is in the compiler proper (`cc1'),
  925.      run your source file through the C preprocessor by doing `gcc -E
  926.      SOURCEFILE > OUTFILE', then include the contents of OUTFILE in the
  927.      bug report.  (When you do this, use the same `-I', `-D' or `-U'
  928.      options that you used in actual compilation.)
  929.  
  930.      A single statement is not enough of an example.  In order to
  931.      compile it, it must be embedded in a complete file of compiler
  932.      input; and the bug might depend on the details of how this is done.
  933.  
  934.      Without a real example one can compile, all anyone can do about
  935.      your bug report is wish you luck.  It would be futile to try to
  936.      guess how to provoke the bug.  For example, bugs in register
  937.      allocation and reloading frequently depend on every little detail
  938.      of the function they happen in.
  939.  
  940.      Even if the input file that fails comes from a GNU program, you
  941.      should still send the complete test case.  Don't ask the GNU CC
  942.      maintainers to do the extra work of obtaining the program in
  943.      question--they are all overworked as it is.  Also, the problem may
  944.      depend on what is in the header files on your system; it is
  945.      unreliable for the GNU CC maintainers to try the problem with the
  946.      header files available to them.  By sending CPP output, you can
  947.      eliminate this source of uncertainty.
  948.  
  949.    * The command arguments you gave GNU CC or GNU C++ to compile that
  950.      example and observe the bug.  For example, did you use `-O'?  To
  951.      guarantee you won't omit something important, list all the options.
  952.  
  953.      If we were to try to guess the arguments, we would probably guess
  954.      wrong and then we would not encounter the bug.
  955.  
  956.    * The type of machine you are using, and the operating system name
  957.      and version number.
  958.  
  959.    * The operands you gave to the `configure' command when you installed
  960.      the compiler.
  961.  
  962.    * A complete list of any modifications you have made to the compiler
  963.      source.  (We don't promise to investigate the bug unless it
  964.      happens in an unmodified compiler.  But if you've made
  965.      modifications and don't tell us, then you are sending us on a wild
  966.      goose chase.)
  967.  
  968.      Be precise about these changes.  A description in English is not
  969.      enough--send a context diff for them.
  970.  
  971.      Adding files of your own (such as a machine description for a
  972.      machine we don't support) is a modification of the compiler source.
  973.  
  974.    * Details of any other deviations from the standard procedure for
  975.      installing GNU CC.
  976.  
  977.    * A description of what behavior you observe that you believe is
  978.      incorrect.  For example, "The compiler gets a fatal signal," or,
  979.      "The assembler instruction at line 208 in the output is incorrect."
  980.  
  981.      Of course, if the bug is that the compiler gets a fatal signal,
  982.      then one can't miss it.  But if the bug is incorrect output, the
  983.      maintainer might not notice unless it is glaringly wrong.  None of
  984.      us has time to study all the assembler code from a 50-line C
  985.      program just on the chance that one instruction might be wrong. 
  986.      We need *you* to do this part!
  987.  
  988.      Even if the problem you experience is a fatal signal, you should
  989.      still say so explicitly.  Suppose something strange is going on,
  990.      such as, your copy of the compiler is out of synch, or you have
  991.      encountered a bug in the C library on your system.  (This has
  992.      happened!)  Your copy might crash and the copy here would not.  If
  993.      you said to expect a crash, then when the compiler here fails to
  994.      crash, we would know that the bug was not happening.  If you don't
  995.      say to expect a crash, then we would not know whether the bug was
  996.      happening.  We would not be able to draw any conclusion from our
  997.      observations.
  998.  
  999.      If the problem is a diagnostic when compiling GNU CC with some
  1000.      other compiler, say whether it is a warning or an error.
  1001.  
  1002.      Often the observed symptom is incorrect output when your program
  1003.      is run. Sad to say, this is not enough information unless the
  1004.      program is short and simple.  None of us has time to study a large
  1005.      program to figure out how it would work if compiled correctly,
  1006.      much less which line of it was compiled wrong.  So you will have
  1007.      to do that.  Tell us which source line it is, and what incorrect
  1008.      result happens when that line is executed.  A person who
  1009.      understands the program can find this as easily as finding a bug
  1010.      in the program itself.
  1011.  
  1012.    * If you send examples of assembler code output from GNU CC or GNU
  1013.      C++, please use `-g' when you make them.  The debugging information
  1014.      includes source line numbers which are essential for correlating
  1015.      the output with the input.
  1016.  
  1017.    * If you wish to mention something in the GNU CC source, refer to it
  1018.      by context, not by line number.
  1019.  
  1020.      The line numbers in the development sources don't match those in
  1021.      your sources.  Your line numbers would convey no useful
  1022.      information to the maintainers.
  1023.  
  1024.    * Additional information from a debugger might enable someone to
  1025.      find a problem on a machine which he does not have available. 
  1026.      However, you need to think when you collect this information if
  1027.      you want it to have any chance of being useful.
  1028.  
  1029.      For example, many people send just a backtrace, but that is never
  1030.      useful by itself.  A simple backtrace with arguments conveys little
  1031.      about GNU CC because the compiler is largely data-driven; the same
  1032.      functions are called over and over for different RTL insns, doing
  1033.      different things depending on the details of the insn.
  1034.  
  1035.      Most of the arguments listed in the backtrace are useless because
  1036.      they are pointers to RTL list structure.  The numeric values of the
  1037.      pointers, which the debugger prints in the backtrace, have no
  1038.      significance whatever; all that matters is the contents of the
  1039.      objects they point to (and most of the contents are other such
  1040.      pointers).
  1041.  
  1042.      In addition, most compiler passes consist of one or more loops that
  1043.      scan the RTL insn sequence.  The most vital piece of information
  1044.      about such a loop--which insn it has reached--is usually in a
  1045.      local variable, not in an argument.
  1046.  
  1047.      What you need to provide in addition to a backtrace are the values
  1048.      of the local variables for several stack frames up.  When a local
  1049.      variable or an argument is an RTX, first print its value and then
  1050.      use the GDB command `pr' to print the RTL expression that it points
  1051.      to.  (If GDB doesn't run on your machine, use your debugger to call
  1052.      the function `debug_rtx' with the RTX as an argument.)  In
  1053.      general, whenever a variable is a pointer, its value is no use
  1054.      without the data it points to.
  1055.  
  1056.    Here are some things that are not necessary:
  1057.  
  1058.    * A description of the envelope of the bug.
  1059.  
  1060.      Often people who encounter a bug spend a lot of time investigating
  1061.      which changes to the input file will make the bug go away and which
  1062.      changes will not affect it.
  1063.  
  1064.      This is often time consuming and not very useful, because the way
  1065.      we will find the bug is by running a single example under the
  1066.      debugger with breakpoints, not by pure deduction from a series of
  1067.      examples.  You might as well save your time for something else.
  1068.  
  1069.      Of course, if you can find a simpler example to report *instead* of
  1070.      the original one, that is a convenience.  Errors in the output
  1071.      will be easier to spot, running under the debugger will take less
  1072.      time, etc. Most GNU CC bugs involve just one function, so the most
  1073.      straightforward way to simplify an example is to delete all the
  1074.      function definitions except the one where the bug occurs.  Those
  1075.      earlier in the file may be replaced by external declarations if
  1076.      the crucial function depends on them.  (Exception: inline
  1077.      functions may affect compilation of functions defined later in the
  1078.      file.)
  1079.  
  1080.      However, simplification is not vital; if you don't want to do this,
  1081.      report the bug anyway and send the entire test case you used.
  1082.  
  1083.    * In particular, some people insert conditionals `#ifdef BUG' around
  1084.      a statement which, if removed, makes the bug not happen.  These
  1085.      are just clutter; we won't pay any attention to them anyway. 
  1086.      Besides, you should send us cpp output, and that can't have
  1087.      conditionals.
  1088.  
  1089.    * A patch for the bug.
  1090.  
  1091.      A patch for the bug is useful if it is a good one.  But don't omit
  1092.      the necessary information, such as the test case, on the
  1093.      assumption that a patch is all we need.  We might see problems
  1094.      with your patch and decide to fix the problem another way, or we
  1095.      might not understand it at all.
  1096.  
  1097.      Sometimes with a program as complicated as GNU CC it is very hard
  1098.      to construct an example that will make the program follow a
  1099.      certain path through the code.  If you don't send the example, we
  1100.      won't be able to construct one, so we won't be able to verify that
  1101.      the bug is fixed.
  1102.  
  1103.      And if we can't understand what bug you are trying to fix, or why
  1104.      your patch should be an improvement, we won't install it.  A test
  1105.      case will help us to understand.
  1106.  
  1107.      *Note Sending Patches::, for guidelines on how to make it easy for
  1108.      us to understand and install your patches.
  1109.  
  1110.    * A guess about what the bug is or what it depends on.
  1111.  
  1112.      Such guesses are usually wrong.  Even I can't guess right about
  1113.      such things without first using the debugger to find the facts.
  1114.  
  1115.    * A core dump file.
  1116.  
  1117.      We have no way of examining a core dump for your type of machine
  1118.      unless we have an identical system--and if we do have one, we
  1119.      should be able to reproduce the crash ourselves.
  1120.  
  1121.