OSDN Git Service

* doc/gcc.texi: Use @defcodeindex for the index of options. Add
[pf3gnuchains/gcc-fork.git] / gcc / doc / gcc.texi
1 \input texinfo  @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename gcc.info
4 @c @setfilename usegcc.info
5 @c @setfilename portgcc.info
6 @c To produce the full manual, use the "gcc.info" setfilename, and
7 @c make sure the following do NOT begin with '@c' (and the @clear lines DO)
8 @set INTERNALS
9 @set USING
10 @c To produce a user-only manual, use the "usegcc.info" setfilename, and
11 @c make sure the following does NOT begin with '@c':
12 @c @clear INTERNALS
13 @c To produce a porter-only manual, use the "portgcc.info" setfilename,
14 @c and make sure the following does NOT begin with '@c':
15 @c @clear USING
16
17 @c (For FSF printing, turn on smallbook, comment out finalout below;
18 @c that is all that is needed.)
19
20 @c 6/27/96 FSF DO wants smallbook fmt for 1st bound edition.
21 @c @smallbook
22
23 @c i also commented out the finalout command, so if there *are* any
24 @c overfulls, you'll (hopefully) see the rectangle in the right hand
25 @c margin. -mew 15june93
26 @c @finalout
27
28 @c NOTE: checks/things to do:
29 @c
30 @c -have bob do a search in all seven files for "mew" (ideally --mew,
31 @c  but i may have forgotten the occasional "--"..).
32 @c     Just checked... all have `--'!  Bob 22Jul96
33 @c     Use this to search:   grep -n '\-\-mew' *.texi
34 @c -item/itemx, text after all (sub/sub)section titles, etc..
35 @c -consider putting the lists of options on pp 17--> etc in columns or
36 @c  some such.
37 @c -spellcheck
38 @c -continuity of phrasing; ie, bit-field vs bitfield in rtl.texi
39 @c -overfulls.  do a search for "mew" in the files, and you will see
40 @c   overfulls that i noted but could not deal with.
41 @c -have to add text:  beginning of chapter 8
42
43 @c
44 @c anything else?                       --mew 10feb93
45
46 @macro gcctabopt{body}
47 @code{\body\}
48 @end macro
49 @macro gccoptlist{body}
50 @smallexample
51 \body\
52 @end smallexample
53 @end macro
54 @c Makeinfo handles the above macro OK, TeX needs manual line breaks;
55 @c they get lost at some point in handling the macro.  But if @macro is
56 @c used here rather than @alias, it produces double line breaks.
57 @iftex
58 @alias gol = *
59 @end iftex
60 @ifnottex
61 @macro gol
62 @end macro
63 @end ifnottex
64
65 @ifset INTERNALS
66 @ifset USING
67 @settitle Using and Porting the GNU Compiler Collection (GCC)
68 @end ifset
69 @end ifset
70 @c seems reasonable to assume at least one of INTERNALS or USING is set...
71 @ifclear INTERNALS
72 @settitle Using the GNU Compiler Collection
73 @end ifclear
74 @ifclear USING
75 @settitle Porting the GNU Compiler Collection
76 @end ifclear
77
78 @c Create a separate index for command line options.
79 @defcodeindex op
80 @c Merge the standard indexes into a single one.
81 @syncodeindex fn cp
82 @syncodeindex vr cp
83 @syncodeindex ky cp
84 @syncodeindex pg cp
85 @syncodeindex tp cp
86
87 @c %**end of header
88
89 @c Use with @@smallbook.
90
91 @c Cause even numbered pages to be printed on the left hand side of
92 @c the page and odd numbered pages to be printed on the right hand
93 @c side of the page.  Using this, you can print on both sides of a
94 @c sheet of paper and have the text on the same part of the sheet.
95
96 @c The text on right hand pages is pushed towards the right hand
97 @c margin and the text on left hand pages is pushed toward the left
98 @c hand margin.
99 @c (To provide the reverse effect, set bindingoffset to -0.75in.)
100
101 @c @tex
102 @c \global\bindingoffset=0.75in
103 @c \global\normaloffset =0.75in
104 @c @end tex
105
106 @ifnottex
107 @dircategory Programming
108 @direntry
109 * gcc: (gcc).                  The GNU Compiler Collection.
110 @end direntry
111 @ifset INTERNALS
112 @ifset USING
113 This file documents the use and the internals of the GNU compiler.
114 @end ifset
115 @end ifset
116 @ifclear USING
117 This file documents the internals of the GNU compiler.
118 @end ifclear
119 @ifclear INTERNALS
120 This file documents the use of the GNU compiler.
121 @end ifclear
122 @sp 1
123 Published by the Free Software Foundation@*
124 59 Temple Place - Suite 330@*
125 Boston, MA 02111-1307 USA
126 @sp 1
127 @c When you update the list of years below, search for copyright{} and
128 @c update the other copy too.
129 Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
130 1999, 2000, 2001 Free Software Foundation, Inc.
131 @sp 1
132 Permission is granted to copy, distribute and/or modify this document
133 under the terms of the GNU Free Documentation License, Version 1.1 or
134 any later version published by the Free Software Foundation; with the
135 Invariant Sections being ``GNU General Public License'' and ``Funding
136 Free Software'', the Front-Cover texts being (a) (see below), and with
137 the Back-Cover Texts being (b) (see below).  A copy of the license is
138 included in the section entitled ``GNU Free Documentation License''.
139
140 (a) The FSF's Front-Cover Text is:
141
142      A GNU Manual
143
144 (b) The FSF's Back-Cover Text is:
145
146      You have freedom to copy and modify this GNU Manual, like GNU
147      software.  Copies published by the Free Software Foundation raise
148      funds for GNU development.
149 @end ifnottex
150
151 @setchapternewpage odd
152 @c @finalout
153 @titlepage
154 @ifset INTERNALS
155 @ifset USING
156 @center @titlefont{Using and Porting the GNU Compiler Collection}
157
158 @end ifset
159 @end ifset
160 @ifclear INTERNALS
161 @title Using the GNU Compiler Collection
162 @end ifclear
163 @ifclear USING
164 @title Porting the GNU Compiler Collection
165 @end ifclear
166 @sp 2
167 @center Richard M. Stallman
168 @sp 3
169 @center Last updated 9 May 2001
170 @sp 1
171 @c The version number appears five times more in this file.
172
173 @center for gcc-3.1
174 @page
175 @vskip 0pt plus 1filll
176 Copyright @copyright{} 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1998,
177 1999, 2000, 2001  Free Software Foundation, Inc.
178 @sp 2
179 For GCC Version 3.1@*
180 @sp 1
181 Published by the Free Software Foundation @*
182 59 Temple Place - Suite 330@*
183 Boston, MA 02111-1307, USA@*
184 Last printed April, 1998.@*
185 Printed copies are available for $50 each.@*
186 ISBN 1-882114-37-X
187 @sp 1
188 Permission is granted to copy, distribute and/or modify this document
189 under the terms of the GNU Free Documentation License, Version 1.1 or
190 any later version published by the Free Software Foundation; with the
191 Invariant Sections being ``GNU General Public License'', the Front-Cover
192 texts being (a) (see below), and with the Back-Cover Texts being (b)
193 (see below).  A copy of the license is included in the section entitled
194 ``GNU Free Documentation License''.
195
196 (a) The FSF's Front-Cover Text is:
197
198      A GNU Manual
199
200 (b) The FSF's Back-Cover Text is:
201
202      You have freedom to copy and modify this GNU Manual, like GNU
203      software.  Copies published by the Free Software Foundation raise
204      funds for GNU development.
205 @end titlepage
206 @summarycontents
207 @contents
208 @page
209
210 @node Top, G++ and GCC,, (DIR)
211 @top Introduction
212 @cindex introduction
213
214 @ifset INTERNALS
215 @ifset USING
216 This manual documents how to run, install and port the GNU
217 compiler, as well as its new features and incompatibilities, and how to
218 report bugs.  It corresponds to GCC version 3.1.
219 @end ifset
220 @end ifset
221
222 @ifclear INTERNALS
223 This manual documents how to run and install the GNU compiler,
224 as well as its new features and incompatibilities, and how to report
225 bugs.  It corresponds to GCC version 3.1.
226 @end ifclear
227 @ifclear USING
228 This manual documents how to port the GNU compiler,
229 as well as its new features and incompatibilities, and how to report
230 bugs.  It corresponds to GCC version 3.1.
231 @end ifclear
232
233 @menu
234 @ifset USING
235 * G++ and GCC::     You can compile C or C++ programs.
236 * Standards::       Language standards supported by GCC.
237 * Invoking GCC::    Command options supported by @samp{gcc}.
238 * Installation::    How to configure, compile and install GCC.
239 * C Extensions::    GNU extensions to the C language family.
240 * C++ Extensions::  GNU extensions to the C++ language.
241 * Objective C::     GNU Objective-C runtime features.
242 * Gcov::            gcov: a GCC test coverage program.
243 * Trouble::         If you have trouble installing GCC.
244 * Bugs::            How, why and where to report bugs.
245 * Service::         How to find suppliers of support for GCC.
246 * Contributing::    How to contribute to testing and developing GCC.
247 * VMS::             Using GCC on VMS.
248 * Makefile::        List of Makefile targets.
249 @end ifset
250 @ifset INTERNALS
251 * Portability::     Goals of GCC's portability features.
252 * Interface::       Function-call interface of GCC output.
253 * Passes::          Order of passes, what they do, and what each file is for.
254 * Trees::           The source representation used by the C and C++ front-ends.
255 * RTL::             The intermediate representation that most passes work on.
256 * Machine Desc::    How to write machine description instruction patterns.
257 * Target Macros::   How to write the machine description C macros.
258 * Config::          Writing the @file{xm-@var{machine}.h} file.
259 * Fragments::       Writing the @file{t-@var{target}} and @file{x-@var{host}} files.
260 @end ifset
261
262 * Funding::         How to help assure funding for free software.
263 * GNU/Linux::       Linux and the GNU Project
264
265 * Copying::         GNU General Public License says
266                      how you can copy and share GCC.
267 * GNU Free Documentation License:: How you can copy and share this manual.
268 * Contributors::    People who have contributed to GCC.
269
270 * Option Index::    Index to command line options.
271 * Index::           Index of concepts and symbol names.
272 @end menu
273
274 @ifset USING
275 @node G++ and GCC
276 @chapter Compile C, C++, Objective C, Fortran, Java or CHILL
277
278 @cindex Objective C
279 @cindex Fortran
280 @cindex Java
281 @cindex CHILL
282 Several versions of the compiler (C, C++, Objective C, Fortran, Java
283 and CHILL) are integrated; this is why we use the name
284 ``GNU Compiler Collection''. GCC can compile programs written in any of these
285 languages. The Fortran, CHILL, and Java compilers are described in
286 separate manuals.
287
288 @cindex GCC
289 ``GCC'' is a common shorthand term for the GNU Compiler Collection.  This is both
290 the most general name for the compiler, and the name used when the
291 emphasis is on compiling C programs (as the abbreviation formerly
292 stood for ``GNU C Compiler'').
293
294 @cindex C++
295 @cindex G++
296 When referring to C++ compilation, it is usual to call the compiler
297 ``G++''.  Since there is only one compiler, it is also accurate to call
298 it ``GCC'' no matter what the language context; however, the term
299 ``G++'' is more useful when the emphasis is on compiling C++ programs.
300
301 We use the name ``GCC'' to refer to the compilation system as a
302 whole, and more specifically to the language-independent part of the
303 compiler.  For example, we refer to the optimization options as
304 affecting the behavior of ``GCC'' or sometimes just ``the compiler''.
305
306 Front ends for other languages, such as Ada 95 and Pascal exist but
307 have not yet been integrated into GCC. These front-ends, like that for C++,
308 are built in subdirectories of GCC and link to it.  The result is an
309 integrated compiler that can compile programs written in C, C++,
310 Objective C, or any of the languages for which you have installed front
311 ends.
312
313 In this manual, we only discuss the options for the C, Objective-C, and
314 C++ compilers and those of the GCC core.  Consult the documentation
315 of the other front ends for the options to use when compiling programs
316 written in other languages.
317
318 @cindex compiler compared to C++ preprocessor
319 @cindex intermediate C version, nonexistent
320 @cindex C intermediate output, nonexistent
321 G++ is a @emph{compiler}, not merely a preprocessor.  G++ builds object
322 code directly from your C++ program source.  There is no intermediate C
323 version of the program.  (By contrast, for example, some other
324 implementations use a program that generates a C program from your C++
325 source.)  Avoiding an intermediate C representation of the program means
326 that you get better object code, and better debugging information.  The
327 GNU debugger, GDB, works with this information in the object code to
328 give you comprehensive C++ source-level editing capabilities
329 (@pxref{C,,C and C++,gdb.info, Debugging with GDB}).
330
331 @c FIXME!  Someone who knows something about Objective C ought to put in
332 @c a paragraph or two about it here, and move the index entry down when
333 @c there is more to point to than the general mention in the 1st par.
334
335 @node Standards
336 @chapter Language Standards Supported by GCC
337 @cindex C standard
338 @cindex C standards
339 @cindex ANSI C standard
340 @cindex ANSI C
341 @cindex ANSI C89
342 @cindex C89
343 @cindex ANSI X3.159-1989
344 @cindex X3.159-1989
345 @cindex ISO C standard
346 @cindex ISO C
347 @cindex ISO C89
348 @cindex ISO C90
349 @cindex ISO/IEC 9899
350 @cindex ISO 9899
351 @cindex C90
352 @cindex ISO C94
353 @cindex C94
354 @cindex ISO C95
355 @cindex C95
356 @cindex ISO C99
357 @cindex C99
358 @cindex ISO C9X
359 @cindex C9X
360 @cindex Technical Corrigenda
361 @cindex TC1
362 @cindex Technical Corrigendum 1
363 @cindex TC2
364 @cindex Technical Corrigendum 2
365 @cindex AMD1
366 @cindex freestanding implementation
367 @cindex freestanding environment
368 @cindex hosted implementation
369 @cindex hosted environment
370 @findex __STDC_HOSTED__
371
372 For each language compiled by GCC for which there is a standard, GCC
373 attempts to follow one or more versions of that standard, possibly
374 with some exceptions, and possibly with some extensions.
375
376 GCC supports three versions of the C standard, although support for
377 the most recent version is not yet complete.
378
379 @opindex std
380 @opindex ansi
381 @opindex pedantic
382 @opindex pedantic-errors
383 The original ANSI C standard (X3.159-1989) was ratified in 1989 and
384 published in 1990.  This standard was ratified as an ISO standard
385 (ISO/IEC 9899:1990) later in 1990.  There were no technical
386 differences between these publications, although the sections of the
387 ANSI standard were renumbered and became clauses in the ISO standard.
388 This standard, in both its forms, is commonly known as @dfn{C89}, or
389 occasionally as @dfn{C90}, from the dates of ratification.  The ANSI
390 standard, but not the ISO standard, also came with a Rationale
391 document.  To select this standard in GCC, use one of the options
392 @option{-ansi}, @option{-std=c89} or @option{-std=iso9899:1990}; to obtain
393 all the diagnostics required by the standard, you should also specify
394 @option{-pedantic} (or @option{-pedantic-errors} if you want them to be
395 errors rather than warnings).  @xref{C Dialect Options,,Options
396 Controlling C Dialect}.
397
398 Errors in the 1990 ISO C standard were corrected in two Technical
399 Corrigenda published in 1994 and 1996.  GCC does not support the
400 uncorrected version.
401
402 An amendment to the 1990 standard was published in 1995.  This
403 amendment added digraphs and @code{__STDC_VERSION__} to the language,
404 but otherwise concerned the library.  This amendment is commonly known
405 as @dfn{AMD1}; the amended standard is sometimes known as @dfn{C94} or
406 @dfn{C95}.  To select this standard in GCC, use the option
407 @option{-std=iso9899:199409} (with, as for other standard versions,
408 @option{-pedantic} to receive all required diagnostics).
409
410 A new edition of the ISO C standard was published in 1999 as ISO/IEC
411 9899:1999, and is commonly known as @dfn{C99}.  GCC has incomplete
412 support for this standard version; see
413 @uref{http://gcc.gnu.org/c99status.html} for details.  To select this
414 standard, use @option{-std=c99} or @option{-std=iso9899:1999}.  (While in
415 development, drafts of this standard version were referred to as
416 @dfn{C9X}.)
417
418 @opindex traditional
419 GCC also has some limited support for traditional (pre-ISO) C with the
420 @option{-traditional} option.  This support may be of use for compiling
421 some very old programs that have not been updated to ISO C, but should
422 not be used for new programs.  It will not work with some modern C
423 libraries such as the GNU C library.
424
425 By default, GCC provides some extensions to the C language that on
426 rare occasions conflict with the C standard.  @xref{C
427 Extensions,,Extensions to the C Language Family}.  Use of the
428 @option{-std} options listed above will disable these extensions where
429 they conflict with the C standard version selected.  You may also
430 select an extended version of the C language explicitly with
431 @option{-std=gnu89} (for C89 with GNU extensions) or @option{-std=gnu99}
432 (for C99 with GNU extensions).  The default, if no C language dialect
433 options are given, is @option{-std=gnu89}; this will change to
434 @option{-std=gnu99} in some future release when the C99 support is
435 complete.  Some features that are part of the C99 standard are
436 accepted as extensions in C89 mode.
437
438 The ISO C standard defines (in clause 4) two classes of conforming
439 implementation.  A @dfn{conforming hosted implementation} supports the
440 whole standard including all the library facilities; a @dfn{conforming
441 freestanding implementation} is only required to provide certain
442 library facilities: those in @code{<float.h>}, @code{<limits.h>},
443 @code{<stdarg.h>}, and @code{<stddef.h>}; since AMD1, also those in
444 @code{<iso646.h>}; and in C99, also those in @code{<stdbool.h>} and
445 @code{<stdint.h>}.  In addition, complex types, added in C99, are not
446 required for freestanding implementations.  The standard also defines
447 two environments for programs, a @dfn{freestanding environment},
448 required of all implementations and which may not have library
449 facilities beyond those required of freestanding implementations,
450 where the handling of program startup and termination are
451 implementation-defined, and a @dfn{hosted environment}, which is not
452 required, in which all the library facilities are provided and startup
453 is through a function @code{int main (void)} or @code{int main (int,
454 char *[])}.  An OS kernel would be a freestanding environment; a
455 program using the facilities of an operating system would normally be
456 in a hosted implementation.
457
458 @opindex ffreestanding
459 GNU CC aims towards being usable as a conforming freestanding
460 implementation, or as the compiler for a conforming hosted
461 implementation.  By default, it will act as the compiler for a hosted
462 implementation, defining @code{__STDC_HOSTED__} as @code{1} and
463 presuming that when the names of ISO C functions are used, they have
464 the semantics defined in the standard.  To make it act as a conforming
465 freestanding implementation for a freestanding environment, use the
466 option @option{-ffreestanding}; it will then define
467 @code{__STDC_HOSTED__} to @code{0} and not make assumptions about the
468 meanings of function names from the standard library.  To build an OS
469 kernel, you may well still need to make your own arrangements for
470 linking and startup.  @xref{C Dialect Options,,Options Controlling C
471 Dialect}.
472
473 GNU CC does not provide the library facilities required only of hosted
474 implementations, nor yet all the facilities required by C99 of
475 freestanding implementations; to use the facilities of a hosted
476 environment, you will need to find them elsewhere (for example, in the
477 GNU C library).  @xref{Standard Libraries,,Standard Libraries}.
478
479 For references to Technical Corrigenda, Rationale documents and
480 information concerning the history of C that is available online, see
481 @uref{http://gcc.gnu.org/readings.html}
482
483 @c FIXME: details of C++ standard.
484
485 There is no formal written standard for Objective-C.  The most
486 authoritative manual is ``Object-Oriented Programming and the
487 Objective-C Language'', available at a number of web sites;
488 @uref{http://developer.apple.com/techpubs/macosx/Cocoa/ObjectiveC/} has a
489 recent version, while @uref{http://www.toodarkpark.org/computers/objc/}
490 is an older example.  @uref{http://www.gnustep.org} includes useful
491 information as well.
492
493 @xref{Language,,The GNU Fortran Language, g77, Using and Porting GNU
494 Fortran}, for details of the Fortran language supported by GCC.
495
496 @xref{Compatibility,,Compatibility with the Java Platform, gcj, GNU gcj},
497 for details of compatibility between @code{gcj} and the Java Platform.
498
499 @xref{References,,Language Definition References, chill, GNU Chill},
500 for details of the CHILL standard.
501
502 @include invoke.texi
503
504 @include install-old.texi
505
506 @include extend.texi
507
508 @include objc.texi
509
510 @include gcov.texi
511
512 @node Trouble
513 @chapter Known Causes of Trouble with GCC
514 @cindex bugs, known
515 @cindex installation trouble
516 @cindex known causes of trouble
517
518 This section describes known problems that affect users of GCC.  Most
519 of these are not GCC bugs per se---if they were, we would fix them.
520 But the result for a user may be like the result of a bug.
521
522 Some of these problems are due to bugs in other software, some are
523 missing features that are too much work to add, and some are places
524 where people's opinions differ as to what is best.
525
526 @menu
527 * Actual Bugs::               Bugs we will fix later.
528 * Cross-Compiler Problems::   Common problems of cross compiling with GCC.
529 * Interoperation::      Problems using GCC with other compilers,
530                            and with certain linkers, assemblers and debuggers.
531 * External Bugs::       Problems compiling certain programs.
532 * Incompatibilities::   GCC is incompatible with traditional C.
533 * Fixed Headers::       GNU C uses corrected versions of system header files.
534                            This is necessary, but doesn't always work smoothly.
535 * Standard Libraries::  GNU C uses the system C library, which might not be
536                            compliant with the ISO C standard.
537 * Disappointments::     Regrettable things we can't change, but not quite bugs.
538 * C++ Misunderstandings::     Common misunderstandings with GNU C++.
539 * Protoize Caveats::    Things to watch out for when using @code{protoize}.
540 * Non-bugs::            Things we think are right, but some others disagree.
541 * Warnings and Errors:: Which problems in your code get warnings,
542                          and which get errors.
543 @end menu
544
545 @node Actual Bugs
546 @section Actual Bugs We Haven't Fixed Yet
547
548 @itemize @bullet
549 @item
550 The @code{fixincludes} script interacts badly with automounters; if the
551 directory of system header files is automounted, it tends to be
552 unmounted while @code{fixincludes} is running.  This would seem to be a
553 bug in the automounter.  We don't know any good way to work around it.
554
555 @item
556 The @code{fixproto} script will sometimes add prototypes for the
557 @code{sigsetjmp} and @code{siglongjmp} functions that reference the
558 @code{jmp_buf} type before that type is defined.  To work around this,
559 edit the offending file and place the typedef in front of the
560 prototypes.
561
562 @item
563 @opindex pedantic-errors
564 When @option{-pedantic-errors} is specified, GCC will incorrectly give
565 an error message when a function name is specified in an expression
566 involving the comma operator.
567 @end itemize
568
569 @node Cross-Compiler Problems
570 @section Cross-Compiler Problems
571
572 You may run into problems with cross compilation on certain machines,
573 for several reasons.
574
575 @itemize @bullet
576 @item
577 Cross compilation can run into trouble for certain machines because
578 some target machines' assemblers require floating point numbers to be
579 written as @emph{integer} constants in certain contexts.
580
581 The compiler writes these integer constants by examining the floating
582 point value as an integer and printing that integer, because this is
583 simple to write and independent of the details of the floating point
584 representation.  But this does not work if the compiler is running on
585 a different machine with an incompatible floating point format, or
586 even a different byte-ordering.
587
588 In addition, correct constant folding of floating point values
589 requires representing them in the target machine's format.
590 (The C standard does not quite require this, but in practice
591 it is the only way to win.)
592
593 It is now possible to overcome these problems by defining macros such
594 as @code{REAL_VALUE_TYPE}.  But doing so is a substantial amount of
595 work for each target machine.
596 @ifset INTERNALS
597 @xref{Cross-compilation}.
598 @end ifset
599 @ifclear INTERNALS
600 @xref{Cross-compilation,,Cross Compilation and Floating Point Format,
601 gcc.info, Using and Porting GCC}.
602 @end ifclear
603
604 @item
605 At present, the program @file{mips-tfile} which adds debug
606 support to object files on MIPS systems does not work in a cross
607 compile environment.
608 @end itemize
609
610 @node Interoperation
611 @section Interoperation
612
613 This section lists various difficulties encountered in using GNU C or
614 GNU C++ together with other compilers or with the assemblers, linkers,
615 libraries and debuggers on certain systems.
616
617 @itemize @bullet
618 @item
619 Objective C does not work on the RS/6000.
620
621 @item
622 GNU C++ does not do name mangling in the same way as other C++
623 compilers.  This means that object files compiled with one compiler
624 cannot be used with another.
625
626 This effect is intentional, to protect you from more subtle problems.
627 Compilers differ as to many internal details of C++ implementation,
628 including: how class instances are laid out, how multiple inheritance is
629 implemented, and how virtual function calls are handled.  If the name
630 encoding were made the same, your programs would link against libraries
631 provided from other compilers---but the programs would then crash when
632 run.  Incompatible libraries are then detected at link time, rather than
633 at run time.
634
635 @item
636 Older GDB versions sometimes fail to read the output of GCC version
637 2.  If you have trouble, get GDB version 4.4 or later.
638
639 @item
640 @cindex DBX
641 DBX rejects some files produced by GCC, though it accepts similar
642 constructs in output from PCC.  Until someone can supply a coherent
643 description of what is valid DBX input and what is not, there is
644 nothing I can do about these problems.  You are on your own.
645
646 @item
647 The GNU assembler (GAS) does not support PIC.  To generate PIC code, you
648 must use some other assembler, such as @file{/bin/as}.
649
650 @item
651 On some BSD systems, including some versions of Ultrix, use of profiling
652 causes static variable destructors (currently used only in C++) not to
653 be run.
654
655 @item
656 Use of @option{-I/usr/include} may cause trouble.
657
658 Many systems come with header files that won't work with GCC unless
659 corrected by @code{fixincludes}.  The corrected header files go in a new
660 directory; GCC searches this directory before @file{/usr/include}.
661 If you use @option{-I/usr/include}, this tells GCC to search
662 @file{/usr/include} earlier on, before the corrected headers.  The
663 result is that you get the uncorrected header files.
664
665 Instead, you should use these options (when compiling C programs):
666
667 @smallexample
668 -I/usr/local/lib/gcc-lib/@var{target}/@var{version}/include -I/usr/include
669 @end smallexample
670
671 For C++ programs, GCC also uses a special directory that defines C++
672 interfaces to standard C subroutines.  This directory is meant to be
673 searched @emph{before} other standard include directories, so that it
674 takes precedence.  If you are compiling C++ programs and specifying
675 include directories explicitly, use this option first, then the two
676 options above:
677
678 @example
679 -I/usr/local/lib/g++-include
680 @end example
681
682 @ignore
683 @cindex @code{vfork}, for the Sun-4
684 @item
685 There is a bug in @code{vfork} on the Sun-4 which causes the registers
686 of the child process to clobber those of the parent.  Because of this,
687 programs that call @code{vfork} are likely to lose when compiled
688 optimized with GCC when the child code alters registers which contain
689 C variables in the parent.  This affects variables which are live in the
690 parent across the call to @code{vfork}.
691
692 If you encounter this, you can work around the problem by declaring
693 variables @code{volatile} in the function that calls @code{vfork}, until
694 the problem goes away, or by not declaring them @code{register} and not
695 using @option{-O} for those source files.
696 @end ignore
697
698 @item
699 On some SGI systems, when you use @option{-lgl_s} as an option,
700 it gets translated magically to @samp{-lgl_s -lX11_s -lc_s}.
701 Naturally, this does not happen when you use GCC.
702 You must specify all three options explicitly.
703
704 @item
705 On a Sparc, GCC aligns all values of type @code{double} on an 8-byte
706 boundary, and it expects every @code{double} to be so aligned.  The Sun
707 compiler usually gives @code{double} values 8-byte alignment, with one
708 exception: function arguments of type @code{double} may not be aligned.
709
710 As a result, if a function compiled with Sun CC takes the address of an
711 argument of type @code{double} and passes this pointer of type
712 @code{double *} to a function compiled with GCC, dereferencing the
713 pointer may cause a fatal signal.
714
715 One way to solve this problem is to compile your entire program with GNU
716 CC.  Another solution is to modify the function that is compiled with
717 Sun CC to copy the argument into a local variable; local variables
718 are always properly aligned.  A third solution is to modify the function
719 that uses the pointer to dereference it via the following function
720 @code{access_double} instead of directly with @samp{*}:
721
722 @smallexample
723 inline double
724 access_double (double *unaligned_ptr)
725 @{
726   union d2i @{ double d; int i[2]; @};
727
728   union d2i *p = (union d2i *) unaligned_ptr;
729   union d2i u;
730
731   u.i[0] = p->i[0];
732   u.i[1] = p->i[1];
733
734   return u.d;
735 @}
736 @end smallexample
737
738 @noindent
739 Storing into the pointer can be done likewise with the same union.
740
741 @item
742 On Solaris, the @code{malloc} function in the @file{libmalloc.a} library
743 may allocate memory that is only 4 byte aligned.  Since GCC on the
744 Sparc assumes that doubles are 8 byte aligned, this may result in a
745 fatal signal if doubles are stored in memory allocated by the
746 @file{libmalloc.a} library.
747
748 The solution is to not use the @file{libmalloc.a} library.  Use instead
749 @code{malloc} and related functions from @file{libc.a}; they do not have
750 this problem.
751
752 @item
753 Sun forgot to include a static version of @file{libdl.a} with some
754 versions of SunOS (mainly 4.1).  This results in undefined symbols when
755 linking static binaries (that is, if you use @option{-static}).  If you
756 see undefined symbols @code{_dlclose}, @code{_dlsym} or @code{_dlopen}
757 when linking, compile and link against the file
758 @file{mit/util/misc/dlsym.c} from the MIT version of X windows.
759
760 @item
761 The 128-bit long double format that the Sparc port supports currently
762 works by using the architecturally defined quad-word floating point
763 instructions.  Since there is no hardware that supports these
764 instructions they must be emulated by the operating system.  Long
765 doubles do not work in Sun OS versions 4.0.3 and earlier, because the
766 kernel emulator uses an obsolete and incompatible format.  Long doubles
767 do not work in Sun OS version 4.1.1 due to a problem in a Sun library.
768 Long doubles do work on Sun OS versions 4.1.2 and higher, but GCC
769 does not enable them by default.  Long doubles appear to work in Sun OS
770 5.x (Solaris 2.x).
771
772 @item
773 On HP-UX version 9.01 on the HP PA, the HP compiler @code{cc} does not
774 compile GCC correctly.  We do not yet know why.  However, GCC
775 compiled on earlier HP-UX versions works properly on HP-UX 9.01 and can
776 compile itself properly on 9.01.
777
778 @item
779 On the HP PA machine, ADB sometimes fails to work on functions compiled
780 with GCC.  Specifically, it fails to work on functions that use
781 @code{alloca} or variable-size arrays.  This is because GCC doesn't
782 generate HP-UX unwind descriptors for such functions.  It may even be
783 impossible to generate them.
784
785 @item
786 Debugging (@option{-g}) is not supported on the HP PA machine, unless you use
787 the preliminary GNU tools (@pxref{Installation}).
788
789 @item
790 Taking the address of a label may generate errors from the HP-UX
791 PA assembler.  GAS for the PA does not have this problem.
792
793 @item
794 Using floating point parameters for indirect calls to static functions
795 will not work when using the HP assembler.  There simply is no way for GCC
796 to specify what registers hold arguments for static functions when using
797 the HP assembler.  GAS for the PA does not have this problem.
798
799 @item
800 In extremely rare cases involving some very large functions you may
801 receive errors from the HP linker complaining about an out of bounds
802 unconditional branch offset.  This used to occur more often in previous
803 versions of GCC, but is now exceptionally rare.  If you should run
804 into it, you can work around by making your function smaller.
805
806 @item
807 GCC compiled code sometimes emits warnings from the HP-UX assembler of
808 the form:
809
810 @smallexample
811 (warning) Use of GR3 when
812   frame >= 8192 may cause conflict.
813 @end smallexample
814
815 These warnings are harmless and can be safely ignored.
816
817 @item
818 The current version of the assembler (@file{/bin/as}) for the RS/6000
819 has certain problems that prevent the @option{-g} option in GCC from
820 working.  Note that @file{Makefile.in} uses @option{-g} by default when
821 compiling @file{libgcc2.c}.
822
823 IBM has produced a fixed version of the assembler.  The upgraded
824 assembler unfortunately was not included in any of the AIX 3.2 update
825 PTF releases (3.2.2, 3.2.3, or 3.2.3e).  Users of AIX 3.1 should request
826 PTF U403044 from IBM and users of AIX 3.2 should request PTF U416277.
827 See the file @file{README.RS6000} for more details on these updates.
828
829 You can test for the presence of a fixed assembler by using the
830 command
831
832 @smallexample
833 as -u < /dev/null
834 @end smallexample
835
836 @noindent
837 If the command exits normally, the assembler fix already is installed.
838 If the assembler complains that @option{-u} is an unknown flag, you need to
839 order the fix.
840
841 @item
842 On the IBM RS/6000, compiling code of the form
843
844 @smallexample
845 extern int foo;
846
847 @dots{} foo @dots{}
848
849 static int foo;
850 @end smallexample
851
852 @noindent
853 will cause the linker to report an undefined symbol @code{foo}.
854 Although this behavior differs from most other systems, it is not a
855 bug because redefining an @code{extern} variable as @code{static}
856 is undefined in ISO C.
857
858 @item
859 AIX on the RS/6000 provides support (NLS) for environments outside of
860 the United States.  Compilers and assemblers use NLS to support
861 locale-specific representations of various objects including
862 floating-point numbers (@samp{.} vs @samp{,} for separating decimal fractions).
863 There have been problems reported where the library linked with GCC does
864 not produce the same floating-point formats that the assembler accepts.
865 If you have this problem, set the @env{LANG} environment variable to
866 @samp{C} or @samp{En_US}.
867
868 @item
869 @opindex fdollars-in-identifiers
870 Even if you specify @option{-fdollars-in-identifiers},
871 you cannot successfully use @samp{$} in identifiers on the RS/6000 due
872 to a restriction in the IBM assembler.  GAS supports these
873 identifiers.
874
875 @item
876 On the RS/6000, XLC version 1.3.0.0 will miscompile @file{jump.c}.  XLC
877 version 1.3.0.1 or later fixes this problem.  You can obtain XLC-1.3.0.2
878 by requesting PTF 421749 from IBM.
879
880 @item
881 @opindex mno-serialize-volatile
882 There is an assembler bug in versions of DG/UX prior to 5.4.2.01 that
883 occurs when the @samp{fldcr} instruction is used.  GCC uses
884 @samp{fldcr} on the 88100 to serialize volatile memory references.  Use
885 the option @option{-mno-serialize-volatile} if your version of the
886 assembler has this bug.
887
888 @item
889 On VMS, GAS versions 1.38.1 and earlier may cause spurious warning
890 messages from the linker.  These warning messages complain of mismatched
891 psect attributes.  You can ignore them.  @xref{VMS Install}.
892
893 @item
894 On NewsOS version 3, if you include both of the files @file{stddef.h}
895 and @file{sys/types.h}, you get an error because there are two typedefs
896 of @code{size_t}.  You should change @file{sys/types.h} by adding these
897 lines around the definition of @code{size_t}:
898
899 @smallexample
900 #ifndef _SIZE_T
901 #define _SIZE_T
902 @var{actual typedef here}
903 #endif
904 @end smallexample
905
906 @cindex Alliant
907 @item
908 On the Alliant, the system's own convention for returning structures
909 and unions is unusual, and is not compatible with GCC no matter
910 what options are used.
911
912 @cindex RT PC
913 @cindex IBM RT PC
914 @item
915 @opindex mhc-struct-return
916 On the IBM RT PC, the MetaWare HighC compiler (hc) uses a different
917 convention for structure and union returning.  Use the option
918 @option{-mhc-struct-return} to tell GCC to use a convention compatible
919 with it.
920
921 @cindex Vax calling convention
922 @cindex Ultrix calling convention
923 @item
924 @opindex fcall-saved
925 On Ultrix, the Fortran compiler expects registers 2 through 5 to be saved
926 by function calls.  However, the C compiler uses conventions compatible
927 with BSD Unix: registers 2 through 5 may be clobbered by function calls.
928
929 GCC uses the same convention as the Ultrix C compiler.  You can use
930 these options to produce code compatible with the Fortran compiler:
931
932 @smallexample
933 -fcall-saved-r2 -fcall-saved-r3 -fcall-saved-r4 -fcall-saved-r5
934 @end smallexample
935
936 @item
937 On the WE32k, you may find that programs compiled with GCC do not
938 work with the standard shared C library.  You may need to link with
939 the ordinary C compiler.  If you do so, you must specify the following
940 options:
941
942 @smallexample
943 -L/usr/local/lib/gcc-lib/we32k-att-sysv/2.8.1 -lgcc -lc_s
944 @end smallexample
945
946 The first specifies where to find the library @file{libgcc.a}
947 specified with the @option{-lgcc} option.
948
949 GCC does linking by invoking @command{ld}, just as @command{cc} does, and
950 there is no reason why it @emph{should} matter which compilation program
951 you use to invoke @command{ld}.  If someone tracks this problem down,
952 it can probably be fixed easily.
953
954 @item
955 On the Alpha, you may get assembler errors about invalid syntax as a
956 result of floating point constants.  This is due to a bug in the C
957 library functions @code{ecvt}, @code{fcvt} and @code{gcvt}.  Given valid
958 floating point numbers, they sometimes print @samp{NaN}.
959
960 @item
961 On Irix 4.0.5F (and perhaps in some other versions), an assembler bug
962 sometimes reorders instructions incorrectly when optimization is turned
963 on.  If you think this may be happening to you, try using the GNU
964 assembler; GAS version 2.1 supports ECOFF on Irix.
965
966 @opindex noasmopt
967 Or use the @option{-noasmopt} option when you compile GCC with itself,
968 and then again when you compile your program.  (This is a temporary
969 kludge to turn off assembler optimization on Irix.)  If this proves to
970 be what you need, edit the assembler spec in the file @file{specs} so
971 that it unconditionally passes @option{-O0} to the assembler, and never
972 passes @option{-O2} or @option{-O3}.
973 @end itemize
974
975 @node External Bugs
976 @section Problems Compiling Certain Programs
977
978 @c prevent bad page break with this line
979 Certain programs have problems compiling.
980
981 @itemize @bullet
982 @item
983 Parse errors may occur compiling X11 on a Decstation running Ultrix 4.2
984 because of problems in DEC's versions of the X11 header files
985 @file{X11/Xlib.h} and @file{X11/Xutil.h}.  People recommend adding
986 @option{-I/usr/include/mit} to use the MIT versions of the header files,
987 using the @option{-traditional} switch to turn off ISO C, or fixing the
988 header files by adding this:
989
990 @example
991 #ifdef __STDC__
992 #define NeedFunctionPrototypes 0
993 #endif
994 @end example
995
996 @item
997 On various 386 Unix systems derived from System V, including SCO, ISC,
998 and ESIX, you may get error messages about running out of virtual memory
999 while compiling certain programs.
1000
1001 You can prevent this problem by linking GCC with the GNU malloc
1002 (which thus replaces the malloc that comes with the system).  GNU malloc
1003 is available as a separate package, and also in the file
1004 @file{src/gmalloc.c} in the GNU Emacs 19 distribution.
1005
1006 If you have installed GNU malloc as a separate library package, use this
1007 option when you relink GCC:
1008
1009 @example
1010 MALLOC=/usr/local/lib/libgmalloc.a
1011 @end example
1012
1013 Alternatively, if you have compiled @file{gmalloc.c} from Emacs 19, copy
1014 the object file to @file{gmalloc.o} and use this option when you relink
1015 GCC:
1016
1017 @example
1018 MALLOC=gmalloc.o
1019 @end example
1020 @end itemize
1021
1022 @node Incompatibilities
1023 @section Incompatibilities of GCC
1024 @cindex incompatibilities of GCC
1025 @opindex traditional
1026
1027 There are several noteworthy incompatibilities between GNU C and K&R
1028 (non-ISO) versions of C.  The @option{-traditional} option
1029 eliminates many of these incompatibilities, @emph{but not all}, by
1030 telling GNU C to behave like a K&R C compiler.
1031
1032 @itemize @bullet
1033 @cindex string constants
1034 @cindex read-only strings
1035 @cindex shared strings
1036 @item
1037 GCC normally makes string constants read-only.  If several
1038 identical-looking string constants are used, GCC stores only one
1039 copy of the string.
1040
1041 @cindex @code{mktemp}, and constant strings
1042 One consequence is that you cannot call @code{mktemp} with a string
1043 constant argument.  The function @code{mktemp} always alters the
1044 string its argument points to.
1045
1046 @cindex @code{sscanf}, and constant strings
1047 @cindex @code{fscanf}, and constant strings
1048 @cindex @code{scanf}, and constant strings
1049 Another consequence is that @code{sscanf} does not work on some systems
1050 when passed a string constant as its format control string or input.
1051 This is because @code{sscanf} incorrectly tries to write into the string
1052 constant.  Likewise @code{fscanf} and @code{scanf}.
1053
1054 @opindex fwritable-strings
1055 The best solution to these problems is to change the program to use
1056 @code{char}-array variables with initialization strings for these
1057 purposes instead of string constants.  But if this is not possible,
1058 you can use the @option{-fwritable-strings} flag, which directs GCC
1059 to handle string constants the same way most C compilers do.
1060 @option{-traditional} also has this effect, among others.
1061
1062 @item
1063 @code{-2147483648} is positive.
1064
1065 This is because 2147483648 cannot fit in the type @code{int}, so
1066 (following the ISO C rules) its data type is @code{unsigned long int}.
1067 Negating this value yields 2147483648 again.
1068
1069 @item
1070 GCC does not substitute macro arguments when they appear inside of
1071 string constants.  For example, the following macro in GCC
1072
1073 @example
1074 #define foo(a) "a"
1075 @end example
1076
1077 @noindent
1078 will produce output @code{"a"} regardless of what the argument @var{a} is.
1079
1080 The @option{-traditional} option directs GCC to handle such cases
1081 (among others) in the old-fashioned (non-ISO) fashion.
1082
1083 @cindex @code{setjmp} incompatibilities
1084 @cindex @code{longjmp} incompatibilities
1085 @item
1086 When you use @code{setjmp} and @code{longjmp}, the only automatic
1087 variables guaranteed to remain valid are those declared
1088 @code{volatile}.  This is a consequence of automatic register
1089 allocation.  Consider this function:
1090
1091 @example
1092 jmp_buf j;
1093
1094 foo ()
1095 @{
1096   int a, b;
1097
1098   a = fun1 ();
1099   if (setjmp (j))
1100     return a;
1101
1102   a = fun2 ();
1103   /* @r{@code{longjmp (j)} may occur in @code{fun3}.} */
1104   return a + fun3 ();
1105 @}
1106 @end example
1107
1108 Here @code{a} may or may not be restored to its first value when the
1109 @code{longjmp} occurs.  If @code{a} is allocated in a register, then
1110 its first value is restored; otherwise, it keeps the last value stored
1111 in it.
1112
1113 @opindex W
1114 If you use the @option{-W} option with the @option{-O} option, you will
1115 get a warning when GCC thinks such a problem might be possible.
1116
1117 The @option{-traditional} option directs GNU C to put variables in
1118 the stack by default, rather than in registers, in functions that
1119 call @code{setjmp}.  This results in the behavior found in
1120 traditional C compilers.
1121
1122 @item
1123 Programs that use preprocessing directives in the middle of macro
1124 arguments do not work with GCC.  For example, a program like this
1125 will not work:
1126
1127 @example
1128 foobar (
1129 #define luser
1130         hack)
1131 @end example
1132
1133 ISO C does not permit such a construct.  It would make sense to support
1134 it when @option{-traditional} is used, but it is too much work to
1135 implement.
1136
1137 @item
1138 K&R compilers allow comments to cross over an inclusion boundary (i.e.
1139 started in an include file and ended in the including file).  I think
1140 this would be quite ugly and can't imagine it could be needed.
1141
1142 @cindex external declaration scope
1143 @cindex scope of external declarations
1144 @cindex declaration scope
1145 @item
1146 Declarations of external variables and functions within a block apply
1147 only to the block containing the declaration.  In other words, they
1148 have the same scope as any other declaration in the same place.
1149
1150 In some other C compilers, a @code{extern} declaration affects all the
1151 rest of the file even if it happens within a block.
1152
1153 The @option{-traditional} option directs GNU C to treat all @code{extern}
1154 declarations as global, like traditional compilers.
1155
1156 @item
1157 In traditional C, you can combine @code{long}, etc., with a typedef name,
1158 as shown here:
1159
1160 @example
1161 typedef int foo;
1162 typedef long foo bar;
1163 @end example
1164
1165 In ISO C, this is not allowed: @code{long} and other type modifiers
1166 require an explicit @code{int}.  Because this criterion is expressed
1167 by Bison grammar rules rather than C code, the @option{-traditional}
1168 flag cannot alter it.
1169
1170 @cindex typedef names as function parameters
1171 @item
1172 PCC allows typedef names to be used as function parameters.  The
1173 difficulty described immediately above applies here too.
1174
1175 @item
1176 When in @option{-traditional} mode, GCC allows the following erroneous
1177 pair of declarations to appear together in a given scope:
1178
1179 @example
1180 typedef int foo;
1181 typedef foo foo;
1182 @end example
1183
1184 @item
1185 GCC treats all characters of identifiers as significant, even when in
1186 @option{-traditional} mode.  According to K&R-1 (2.2), ``No more than the
1187 first eight characters are significant, although more may be used.''.
1188 Also according to K&R-1 (2.2), ``An identifier is a sequence of letters
1189 and digits; the first character must be a letter.  The underscore _
1190 counts as a letter.'', but GCC also allows dollar signs in identifiers.
1191
1192 @cindex whitespace
1193 @item
1194 PCC allows whitespace in the middle of compound assignment operators
1195 such as @samp{+=}.  GCC, following the ISO standard, does not
1196 allow this.  The difficulty described immediately above applies here
1197 too.
1198
1199 @cindex apostrophes
1200 @cindex '
1201 @item
1202 GCC complains about unterminated character constants inside of
1203 preprocessing conditionals that fail.  Some programs have English
1204 comments enclosed in conditionals that are guaranteed to fail; if these
1205 comments contain apostrophes, GCC will probably report an error.  For
1206 example, this code would produce an error:
1207
1208 @example
1209 #if 0
1210 You can't expect this to work.
1211 #endif
1212 @end example
1213
1214 The best solution to such a problem is to put the text into an actual
1215 C comment delimited by @samp{/*@dots{}*/}.  However,
1216 @option{-traditional} suppresses these error messages.
1217
1218 @item
1219 Many user programs contain the declaration @samp{long time ();}.  In the
1220 past, the system header files on many systems did not actually declare
1221 @code{time}, so it did not matter what type your program declared it to
1222 return.  But in systems with ISO C headers, @code{time} is declared to
1223 return @code{time_t}, and if that is not the same as @code{long}, then
1224 @samp{long time ();} is erroneous.
1225
1226 The solution is to change your program to use appropriate system headers
1227 (@code{<time.h>} on systems with ISO C headers) and not to declare
1228 @code{time} if the system header files declare it, or failing that to
1229 use @code{time_t} as the return type of @code{time}.
1230
1231 @cindex @code{float} as function value type
1232 @item
1233 When compiling functions that return @code{float}, PCC converts it to
1234 a double.  GCC actually returns a @code{float}.  If you are concerned
1235 with PCC compatibility, you should declare your functions to return
1236 @code{double}; you might as well say what you mean.
1237
1238 @cindex structures
1239 @cindex unions
1240 @item
1241 When compiling functions that return structures or unions, GCC
1242 output code normally uses a method different from that used on most
1243 versions of Unix.  As a result, code compiled with GCC cannot call
1244 a structure-returning function compiled with PCC, and vice versa.
1245
1246 The method used by GCC is as follows: a structure or union which is
1247 1, 2, 4 or 8 bytes long is returned like a scalar.  A structure or union
1248 with any other size is stored into an address supplied by the caller
1249 (usually in a special, fixed register, but on some machines it is passed
1250 on the stack).  The machine-description macros @code{STRUCT_VALUE} and
1251 @code{STRUCT_INCOMING_VALUE} tell GCC where to pass this address.
1252
1253 By contrast, PCC on most target machines returns structures and unions
1254 of any size by copying the data into an area of static storage, and then
1255 returning the address of that storage as if it were a pointer value.
1256 The caller must copy the data from that memory area to the place where
1257 the value is wanted.  GCC does not use this method because it is
1258 slower and nonreentrant.
1259
1260 On some newer machines, PCC uses a reentrant convention for all
1261 structure and union returning.  GCC on most of these machines uses a
1262 compatible convention when returning structures and unions in memory,
1263 but still returns small structures and unions in registers.
1264
1265 @opindex fpcc-struct-return
1266 You can tell GCC to use a compatible convention for all structure and
1267 union returning with the option @option{-fpcc-struct-return}.
1268
1269 @cindex preprocessing tokens
1270 @cindex preprocessing numbers
1271 @item
1272 GNU C complains about program fragments such as @samp{0x74ae-0x4000}
1273 which appear to be two hexadecimal constants separated by the minus
1274 operator.  Actually, this string is a single @dfn{preprocessing token}.
1275 Each such token must correspond to one token in C.  Since this does not,
1276 GNU C prints an error message.  Although it may appear obvious that what
1277 is meant is an operator and two values, the ISO C standard specifically
1278 requires that this be treated as erroneous.
1279
1280 A @dfn{preprocessing token} is a @dfn{preprocessing number} if it
1281 begins with a digit and is followed by letters, underscores, digits,
1282 periods and @samp{e+}, @samp{e-}, @samp{E+}, @samp{E-}, @samp{p+},
1283 @samp{p-}, @samp{P+}, or @samp{P-} character sequences.  (In strict C89
1284 mode, the sequences @samp{p+}, @samp{p-}, @samp{P+} and @samp{P-} cannot
1285 appear in preprocessing numbers.)
1286
1287 To make the above program fragment valid, place whitespace in front of
1288 the minus sign.  This whitespace will end the preprocessing number.
1289 @end itemize
1290
1291 @node Fixed Headers
1292 @section Fixed Header Files
1293
1294 GCC needs to install corrected versions of some system header files.
1295 This is because most target systems have some header files that won't
1296 work with GCC unless they are changed.  Some have bugs, some are
1297 incompatible with ISO C, and some depend on special features of other
1298 compilers.
1299
1300 Installing GCC automatically creates and installs the fixed header
1301 files, by running a program called @code{fixincludes} (or for certain
1302 targets an alternative such as @code{fixinc.svr4}).  Normally, you
1303 don't need to pay attention to this.  But there are cases where it
1304 doesn't do the right thing automatically.
1305
1306 @itemize @bullet
1307 @item
1308 If you update the system's header files, such as by installing a new
1309 system version, the fixed header files of GCC are not automatically
1310 updated.  The easiest way to update them is to reinstall GCC.  (If
1311 you want to be clever, look in the makefile and you can find a
1312 shortcut.)
1313
1314 @item
1315 On some systems, in particular SunOS 4, header file directories contain
1316 machine-specific symbolic links in certain places.  This makes it
1317 possible to share most of the header files among hosts running the
1318 same version of SunOS 4 on different machine models.
1319
1320 The programs that fix the header files do not understand this special
1321 way of using symbolic links; therefore, the directory of fixed header
1322 files is good only for the machine model used to build it.
1323
1324 In SunOS 4, only programs that look inside the kernel will notice the
1325 difference between machine models.  Therefore, for most purposes, you
1326 need not be concerned about this.
1327
1328 It is possible to make separate sets of fixed header files for the
1329 different machine models, and arrange a structure of symbolic links so
1330 as to use the proper set, but you'll have to do this by hand.
1331
1332 @item
1333 On Lynxos, GCC by default does not fix the header files.  This is
1334 because bugs in the shell cause the @code{fixincludes} script to fail.
1335
1336 This means you will encounter problems due to bugs in the system header
1337 files.  It may be no comfort that they aren't GCC's fault, but it
1338 does mean that there's nothing for us to do about them.
1339 @end itemize
1340
1341 @node Standard Libraries
1342 @section Standard Libraries
1343
1344 @opindex Wall
1345 GCC by itself attempts to be a conforming freestanding implementation.
1346 @xref{Standards,,Language Standards Supported by GCC}, for details of
1347 what this means.  Beyond the library facilities required of such an
1348 implementation, the rest of the C library is supplied by the vendor of
1349 the operating system.  If that C library doesn't conform to the C
1350 standards, then your programs might get warnings (especially when using
1351 @option{-Wall}) that you don't expect.
1352
1353 For example, the @code{sprintf} function on SunOS 4.1.3 returns
1354 @code{char *} while the C standard says that @code{sprintf} returns an
1355 @code{int}.  The @code{fixincludes} program could make the prototype for
1356 this function match the Standard, but that would be wrong, since the
1357 function will still return @code{char *}.
1358
1359 If you need a Standard compliant library, then you need to find one, as
1360 GCC does not provide one.  The GNU C library (called @code{glibc})
1361 provides ISO C, POSIX, BSD, SystemV and X/Open compatibility for
1362 GNU/Linux and HURD-based GNU systems; no recent version of it supports
1363 other systems, though some very old versions did.  Version 2.2 of the
1364 GNU C library includes nearly complete C99 support.  You could also ask
1365 your operating system vendor if newer libraries are available.
1366
1367 @node Disappointments
1368 @section Disappointments and Misunderstandings
1369
1370 These problems are perhaps regrettable, but we don't know any practical
1371 way around them.
1372
1373 @itemize @bullet
1374 @item
1375 Certain local variables aren't recognized by debuggers when you compile
1376 with optimization.
1377
1378 This occurs because sometimes GCC optimizes the variable out of
1379 existence.  There is no way to tell the debugger how to compute the
1380 value such a variable ``would have had'', and it is not clear that would
1381 be desirable anyway.  So GCC simply does not mention the eliminated
1382 variable when it writes debugging information.
1383
1384 You have to expect a certain amount of disagreement between the
1385 executable and your source code, when you use optimization.
1386
1387 @cindex conflicting types
1388 @cindex scope of declaration
1389 @item
1390 Users often think it is a bug when GCC reports an error for code
1391 like this:
1392
1393 @example
1394 int foo (struct mumble *);
1395
1396 struct mumble @{ @dots{} @};
1397
1398 int foo (struct mumble *x)
1399 @{ @dots{} @}
1400 @end example
1401
1402 This code really is erroneous, because the scope of @code{struct
1403 mumble} in the prototype is limited to the argument list containing it.
1404 It does not refer to the @code{struct mumble} defined with file scope
1405 immediately below---they are two unrelated types with similar names in
1406 different scopes.
1407
1408 But in the definition of @code{foo}, the file-scope type is used
1409 because that is available to be inherited.  Thus, the definition and
1410 the prototype do not match, and you get an error.
1411
1412 This behavior may seem silly, but it's what the ISO standard specifies.
1413 It is easy enough for you to make your code work by moving the
1414 definition of @code{struct mumble} above the prototype.  It's not worth
1415 being incompatible with ISO C just to avoid an error for the example
1416 shown above.
1417
1418 @item
1419 Accesses to bitfields even in volatile objects works by accessing larger
1420 objects, such as a byte or a word.  You cannot rely on what size of
1421 object is accessed in order to read or write the bitfield; it may even
1422 vary for a given bitfield according to the precise usage.
1423
1424 If you care about controlling the amount of memory that is accessed, use
1425 volatile but do not use bitfields.
1426
1427 @item
1428 GCC comes with shell scripts to fix certain known problems in system
1429 header files.  They install corrected copies of various header files in
1430 a special directory where only GCC will normally look for them.  The
1431 scripts adapt to various systems by searching all the system header
1432 files for the problem cases that we know about.
1433
1434 If new system header files are installed, nothing automatically arranges
1435 to update the corrected header files.  You will have to reinstall GCC
1436 to fix the new header files.  More specifically, go to the build
1437 directory and delete the files @file{stmp-fixinc} and
1438 @file{stmp-headers}, and the subdirectory @code{include}; then do
1439 @samp{make install} again.
1440
1441 @item
1442 @cindex floating point precision
1443 On 68000 and x86 systems, for instance, you can get paradoxical results
1444 if you test the precise values of floating point numbers.  For example,
1445 you can find that a floating point value which is not a NaN is not equal
1446 to itself.  This results from the fact that the floating point registers
1447 hold a few more bits of precision than fit in a @code{double} in memory.
1448 Compiled code moves values between memory and floating point registers
1449 at its convenience, and moving them into memory truncates them.
1450
1451 @opindex ffloat-store
1452 You can partially avoid this problem by using the @option{-ffloat-store}
1453 option (@pxref{Optimize Options}).
1454
1455 @item
1456 On the MIPS, variable argument functions using @file{varargs.h}
1457 cannot have a floating point value for the first argument.  The
1458 reason for this is that in the absence of a prototype in scope,
1459 if the first argument is a floating point, it is passed in a
1460 floating point register, rather than an integer register.
1461
1462 If the code is rewritten to use the ISO standard @file{stdarg.h}
1463 method of variable arguments, and the prototype is in scope at
1464 the time of the call, everything will work fine.
1465
1466 @item
1467 On the H8/300 and H8/300H, variable argument functions must be
1468 implemented using the ISO standard @file{stdarg.h} method of
1469 variable arguments.  Furthermore, calls to functions using @file{stdarg.h}
1470 variable arguments must have a prototype for the called function
1471 in scope at the time of the call.
1472 @end itemize
1473
1474 @node C++ Misunderstandings
1475 @section Common Misunderstandings with GNU C++
1476
1477 @cindex misunderstandings in C++
1478 @cindex surprises in C++
1479 @cindex C++ misunderstandings
1480 C++ is a complex language and an evolving one, and its standard
1481 definition (the ISO C++ standard) was only recently completed.  As a
1482 result, your C++ compiler may occasionally surprise you, even when its
1483 behavior is correct.  This section discusses some areas that frequently
1484 give rise to questions of this sort.
1485
1486 @menu
1487 * Static Definitions::  Static member declarations are not definitions
1488 * Temporaries::         Temporaries may vanish before you expect
1489 * Copy Assignment::     Copy Assignment operators copy virtual bases twice
1490 @end menu
1491
1492 @node Static Definitions
1493 @subsection Declare @emph{and} Define Static Members
1494
1495 @cindex C++ static data, declaring and defining
1496 @cindex static data in C++, declaring and defining
1497 @cindex declaring static data in C++
1498 @cindex defining static data in C++
1499 When a class has static data members, it is not enough to @emph{declare}
1500 the static member; you must also @emph{define} it.  For example:
1501
1502 @example
1503 class Foo
1504 @{
1505   @dots{}
1506   void method();
1507   static int bar;
1508 @};
1509 @end example
1510
1511 This declaration only establishes that the class @code{Foo} has an
1512 @code{int} named @code{Foo::bar}, and a member function named
1513 @code{Foo::method}.  But you still need to define @emph{both}
1514 @code{method} and @code{bar} elsewhere.  According to the ISO
1515 standard, you must supply an initializer in one (and only one) source
1516 file, such as:
1517
1518 @example
1519 int Foo::bar = 0;
1520 @end example
1521
1522 Other C++ compilers may not correctly implement the standard behavior.
1523 As a result, when you switch to @code{g++} from one of these compilers,
1524 you may discover that a program that appeared to work correctly in fact
1525 does not conform to the standard: @code{g++} reports as undefined
1526 symbols any static data members that lack definitions.
1527
1528 @node Temporaries
1529 @subsection Temporaries May Vanish Before You Expect
1530
1531 @cindex temporaries, lifetime of
1532 @cindex portions of temporary objects, pointers to
1533 It is dangerous to use pointers or references to @emph{portions} of a
1534 temporary object.  The compiler may very well delete the object before
1535 you expect it to, leaving a pointer to garbage.  The most common place
1536 where this problem crops up is in classes like string classes,
1537 especially ones that define a conversion function to type @code{char *}
1538 or @code{const char *}---which is one reason why the standard
1539 @code{string} class requires you to call the @code{c_str} member
1540 function.  However, any class that returns a pointer to some internal
1541 structure is potentially subject to this problem.
1542
1543 For example, a program may use a function @code{strfunc} that returns
1544 @code{string} objects, and another function @code{charfunc} that
1545 operates on pointers to @code{char}:
1546
1547 @example
1548 string strfunc ();
1549 void charfunc (const char *);
1550
1551 void
1552 f ()
1553 @{
1554   const char *p = strfunc().c_str();
1555   ...
1556   charfunc (p);
1557   ...
1558   charfunc (p);
1559 @}
1560 @end example
1561
1562 @noindent
1563 In this situation, it may seem reasonable to save a pointer to the C
1564 string returned by the @code{c_str} member function and use that rather
1565 than call @code{c_str} repeatedly.  However, the temporary string
1566 created by the call to @code{strfunc} is destroyed after @code{p} is
1567 initialized, at which point @code{p} is left pointing to freed memory.
1568
1569 Code like this may run successfully under some other compilers,
1570 particularly obsolete cfront-based compilers that delete temporaries
1571 along with normal local variables.  However, the GNU C++ behavior is
1572 standard-conforming, so if your program depends on late destruction of
1573 temporaries it is not portable.
1574
1575 The safe way to write such code is to give the temporary a name, which
1576 forces it to remain until the end of the scope of the name.  For
1577 example:
1578
1579 @example
1580 string& tmp = strfunc ();
1581 charfunc (tmp.c_str ());
1582 @end example
1583
1584 @node Copy Assignment
1585 @subsection Implicit Copy-Assignment for Virtual Bases
1586
1587 When a base class is virtual, only one subobject of the base class
1588 belongs to each full object. Also, the constructors and destructors are
1589 invoked only once, and called from the most-derived class. However, such
1590 objects behave unspecified when being assigned. For example:
1591
1592 @example
1593 struct Base@{
1594   char *name;
1595   Base(char *n) : name(strdup(n))@{@}
1596   Base& operator= (const Base& other)@{
1597    free (name);
1598    name = strdup (other.name);
1599   @}
1600 @};
1601
1602 struct A:virtual Base@{
1603   int val;
1604   A():Base("A")@{@}
1605 @};
1606
1607 struct B:virtual Base@{
1608   int bval;
1609   B():Base("B")@{@}
1610 @};
1611
1612 struct Derived:public A, public B@{
1613   Derived():Base("Derived")@{@}
1614 @};
1615
1616 void func(Derived &d1, Derived &d2)
1617 @{
1618   d1 = d2;
1619 @}
1620 @end example
1621
1622 The C++ standard specifies that @samp{Base::Base} is only called once
1623 when constructing or copy-constructing a Derived object. It is
1624 unspecified whether @samp{Base::operator=} is called more than once when
1625 the implicit copy-assignment for Derived objects is invoked (as it is
1626 inside @samp{func} in the example).
1627
1628 g++ implements the ``intuitive'' algorithm for copy-assignment: assign all
1629 direct bases, then assign all members. In that algorithm, the virtual
1630 base subobject can be encountered many times. In the example, copying
1631 proceeds in the following order: @samp{val}, @samp{name} (via
1632 @code{strdup}), @samp{bval}, and @samp{name} again.
1633
1634 If application code relies on copy-assignment, a user-defined
1635 copy-assignment operator removes any uncertainties. With such an
1636 operator, the application can define whether and how the virtual base
1637 subobject is assigned.
1638
1639 @node Protoize Caveats
1640 @section Caveats of using @command{protoize}
1641
1642 The conversion programs @command{protoize} and @command{unprotoize} can
1643 sometimes change a source file in a way that won't work unless you
1644 rearrange it.
1645
1646 @itemize @bullet
1647 @item
1648 @command{protoize} can insert references to a type name or type tag before
1649 the definition, or in a file where they are not defined.
1650
1651 If this happens, compiler error messages should show you where the new
1652 references are, so fixing the file by hand is straightforward.
1653
1654 @item
1655 There are some C constructs which @command{protoize} cannot figure out.
1656 For example, it can't determine argument types for declaring a
1657 pointer-to-function variable; this you must do by hand.  @command{protoize}
1658 inserts a comment containing @samp{???} each time it finds such a
1659 variable; so you can find all such variables by searching for this
1660 string.  ISO C does not require declaring the argument types of
1661 pointer-to-function types.
1662
1663 @item
1664 Using @command{unprotoize} can easily introduce bugs.  If the program
1665 relied on prototypes to bring about conversion of arguments, these
1666 conversions will not take place in the program without prototypes.
1667 One case in which you can be sure @command{unprotoize} is safe is when
1668 you are removing prototypes that were made with @command{protoize}; if
1669 the program worked before without any prototypes, it will work again
1670 without them.
1671
1672 @opindex Wconversion
1673 You can find all the places where this problem might occur by compiling
1674 the program with the @option{-Wconversion} option.  It prints a warning
1675 whenever an argument is converted.
1676
1677 @item
1678 Both conversion programs can be confused if there are macro calls in and
1679 around the text to be converted.  In other words, the standard syntax
1680 for a declaration or definition must not result from expanding a macro.
1681 This problem is inherent in the design of C and cannot be fixed.  If
1682 only a few functions have confusing macro calls, you can easily convert
1683 them manually.
1684
1685 @item
1686 @command{protoize} cannot get the argument types for a function whose
1687 definition was not actually compiled due to preprocessing conditionals.
1688 When this happens, @command{protoize} changes nothing in regard to such
1689 a function.  @command{protoize} tries to detect such instances and warn
1690 about them.
1691
1692 You can generally work around this problem by using @command{protoize} step
1693 by step, each time specifying a different set of @option{-D} options for
1694 compilation, until all of the functions have been converted.  There is
1695 no automatic way to verify that you have got them all, however.
1696
1697 @item
1698 Confusion may result if there is an occasion to convert a function
1699 declaration or definition in a region of source code where there is more
1700 than one formal parameter list present.  Thus, attempts to convert code
1701 containing multiple (conditionally compiled) versions of a single
1702 function header (in the same vicinity) may not produce the desired (or
1703 expected) results.
1704
1705 If you plan on converting source files which contain such code, it is
1706 recommended that you first make sure that each conditionally compiled
1707 region of source code which contains an alternative function header also
1708 contains at least one additional follower token (past the final right
1709 parenthesis of the function header).  This should circumvent the
1710 problem.
1711
1712 @item
1713 @command{unprotoize} can become confused when trying to convert a function
1714 definition or declaration which contains a declaration for a
1715 pointer-to-function formal argument which has the same name as the
1716 function being defined or declared.  We recommend you avoid such choices
1717 of formal parameter names.
1718
1719 @item
1720 You might also want to correct some of the indentation by hand and break
1721 long lines.  (The conversion programs don't write lines longer than
1722 eighty characters in any case.)
1723 @end itemize
1724
1725 @node Non-bugs
1726 @section Certain Changes We Don't Want to Make
1727
1728 This section lists changes that people frequently request, but which
1729 we do not make because we think GCC is better without them.
1730
1731 @itemize @bullet
1732 @item
1733 Checking the number and type of arguments to a function which has an
1734 old-fashioned definition and no prototype.
1735
1736 Such a feature would work only occasionally---only for calls that appear
1737 in the same file as the called function, following the definition.  The
1738 only way to check all calls reliably is to add a prototype for the
1739 function.  But adding a prototype eliminates the motivation for this
1740 feature.  So the feature is not worthwhile.
1741
1742 @item
1743 Warning about using an expression whose type is signed as a shift count.
1744
1745 Shift count operands are probably signed more often than unsigned.
1746 Warning about this would cause far more annoyance than good.
1747
1748 @item
1749 Warning about assigning a signed value to an unsigned variable.
1750
1751 Such assignments must be very common; warning about them would cause
1752 more annoyance than good.
1753
1754 @item
1755 Warning when a non-void function value is ignored.
1756
1757 Coming as I do from a Lisp background, I balk at the idea that there is
1758 something dangerous about discarding a value.  There are functions that
1759 return values which some callers may find useful; it makes no sense to
1760 clutter the program with a cast to @code{void} whenever the value isn't
1761 useful.
1762
1763 @item
1764 @opindex fshort-enums
1765 Making @option{-fshort-enums} the default.
1766
1767 This would cause storage layout to be incompatible with most other C
1768 compilers.  And it doesn't seem very important, given that you can get
1769 the same result in other ways.  The case where it matters most is when
1770 the enumeration-valued object is inside a structure, and in that case
1771 you can specify a field width explicitly.
1772
1773 @item
1774 Making bitfields unsigned by default on particular machines where ``the
1775 ABI standard'' says to do so.
1776
1777 The ISO C standard leaves it up to the implementation whether a bitfield
1778 declared plain @code{int} is signed or not.  This in effect creates two
1779 alternative dialects of C.
1780
1781 @opindex fsigned-bitfields
1782 @opindex funsigned-bitfields
1783 The GNU C compiler supports both dialects; you can specify the signed
1784 dialect with @option{-fsigned-bitfields} and the unsigned dialect with
1785 @option{-funsigned-bitfields}.  However, this leaves open the question of
1786 which dialect to use by default.
1787
1788 Currently, the preferred dialect makes plain bitfields signed, because
1789 this is simplest.  Since @code{int} is the same as @code{signed int} in
1790 every other context, it is cleanest for them to be the same in bitfields
1791 as well.
1792
1793 Some computer manufacturers have published Application Binary Interface
1794 standards which specify that plain bitfields should be unsigned.  It is
1795 a mistake, however, to say anything about this issue in an ABI.  This is
1796 because the handling of plain bitfields distinguishes two dialects of C.
1797 Both dialects are meaningful on every type of machine.  Whether a
1798 particular object file was compiled using signed bitfields or unsigned
1799 is of no concern to other object files, even if they access the same
1800 bitfields in the same data structures.
1801
1802 A given program is written in one or the other of these two dialects.
1803 The program stands a chance to work on most any machine if it is
1804 compiled with the proper dialect.  It is unlikely to work at all if
1805 compiled with the wrong dialect.
1806
1807 Many users appreciate the GNU C compiler because it provides an
1808 environment that is uniform across machines.  These users would be
1809 inconvenienced if the compiler treated plain bitfields differently on
1810 certain machines.
1811
1812 Occasionally users write programs intended only for a particular machine
1813 type.  On these occasions, the users would benefit if the GNU C compiler
1814 were to support by default the same dialect as the other compilers on
1815 that machine.  But such applications are rare.  And users writing a
1816 program to run on more than one type of machine cannot possibly benefit
1817 from this kind of compatibility.
1818
1819 This is why GCC does and will treat plain bitfields in the same
1820 fashion on all types of machines (by default).
1821
1822 There are some arguments for making bitfields unsigned by default on all
1823 machines.  If, for example, this becomes a universal de facto standard,
1824 it would make sense for GCC to go along with it.  This is something
1825 to be considered in the future.
1826
1827 (Of course, users strongly concerned about portability should indicate
1828 explicitly in each bitfield whether it is signed or not.  In this way,
1829 they write programs which have the same meaning in both C dialects.)
1830
1831 @item
1832 @opindex ansi
1833 @opindex traditional
1834 @opindex std
1835 Undefining @code{__STDC__} when @option{-ansi} is not used.
1836
1837 Currently, GCC defines @code{__STDC__} as long as you don't use
1838 @option{-traditional}.  This provides good results in practice.
1839
1840 Programmers normally use conditionals on @code{__STDC__} to ask whether
1841 it is safe to use certain features of ISO C, such as function
1842 prototypes or ISO token concatenation.  Since plain @command{gcc} supports
1843 all the features of ISO C, the correct answer to these questions is
1844 ``yes''.
1845
1846 Some users try to use @code{__STDC__} to check for the availability of
1847 certain library facilities.  This is actually incorrect usage in an ISO
1848 C program, because the ISO C standard says that a conforming
1849 freestanding implementation should define @code{__STDC__} even though it
1850 does not have the library facilities.  @samp{gcc -ansi -pedantic} is a
1851 conforming freestanding implementation, and it is therefore required to
1852 define @code{__STDC__}, even though it does not come with an ISO C
1853 library.
1854
1855 Sometimes people say that defining @code{__STDC__} in a compiler that
1856 does not completely conform to the ISO C standard somehow violates the
1857 standard.  This is illogical.  The standard is a standard for compilers
1858 that claim to support ISO C, such as @samp{gcc -ansi}---not for other
1859 compilers such as plain @command{gcc}.  Whatever the ISO C standard says
1860 is relevant to the design of plain @command{gcc} without @option{-ansi} only
1861 for pragmatic reasons, not as a requirement.
1862
1863 GCC normally defines @code{__STDC__} to be 1, and in addition
1864 defines @code{__STRICT_ANSI__} if you specify the @option{-ansi} option,
1865 or a @option{-std} option for strict conformance to some version of ISO C.
1866 On some hosts, system include files use a different convention, where
1867 @code{__STDC__} is normally 0, but is 1 if the user specifies strict
1868 conformance to the C Standard.  GCC follows the host convention when
1869 processing system include files, but when processing user files it follows
1870 the usual GNU C convention.
1871
1872 @item
1873 Undefining @code{__STDC__} in C++.
1874
1875 Programs written to compile with C++-to-C translators get the
1876 value of @code{__STDC__} that goes with the C compiler that is
1877 subsequently used.  These programs must test @code{__STDC__}
1878 to determine what kind of C preprocessor that compiler uses:
1879 whether they should concatenate tokens in the ISO C fashion
1880 or in the traditional fashion.
1881
1882 These programs work properly with GNU C++ if @code{__STDC__} is defined.
1883 They would not work otherwise.
1884
1885 In addition, many header files are written to provide prototypes in ISO
1886 C but not in traditional C.  Many of these header files can work without
1887 change in C++ provided @code{__STDC__} is defined.  If @code{__STDC__}
1888 is not defined, they will all fail, and will all need to be changed to
1889 test explicitly for C++ as well.
1890
1891 @item
1892 Deleting ``empty'' loops.
1893
1894 Historically, GCC has not deleted ``empty'' loops under the
1895 assumption that the most likely reason you would put one in a program is
1896 to have a delay, so deleting them will not make real programs run any
1897 faster.
1898
1899 However, the rationale here is that optimization of a nonempty loop
1900 cannot produce an empty one, which holds for C but is not always the
1901 case for C++.
1902
1903 @opindex funroll-loops
1904 Moreover, with @option{-funroll-loops} small ``empty'' loops are already
1905 removed, so the current behavior is both sub-optimal and inconsistent
1906 and will change in the future.
1907
1908 @item
1909 Making side effects happen in the same order as in some other compiler.
1910
1911 @cindex side effects, order of evaluation
1912 @cindex order of evaluation, side effects
1913 It is never safe to depend on the order of evaluation of side effects.
1914 For example, a function call like this may very well behave differently
1915 from one compiler to another:
1916
1917 @example
1918 void func (int, int);
1919
1920 int i = 2;
1921 func (i++, i++);
1922 @end example
1923
1924 There is no guarantee (in either the C or the C++ standard language
1925 definitions) that the increments will be evaluated in any particular
1926 order.  Either increment might happen first.  @code{func} might get the
1927 arguments @samp{2, 3}, or it might get @samp{3, 2}, or even @samp{2, 2}.
1928
1929 @item
1930 Not allowing structures with volatile fields in registers.
1931
1932 Strictly speaking, there is no prohibition in the ISO C standard
1933 against allowing structures with volatile fields in registers, but
1934 it does not seem to make any sense and is probably not what you wanted
1935 to do.  So the compiler will give an error message in this case.
1936
1937 @item
1938 Making certain warnings into errors by default.
1939
1940 Some ISO C testsuites report failure when the compiler does not produce
1941 an error message for a certain program.
1942
1943 @opindex pedantic-errors
1944 ISO C requires a ``diagnostic'' message for certain kinds of invalid
1945 programs, but a warning is defined by GCC to count as a diagnostic.  If
1946 GCC produces a warning but not an error, that is correct ISO C support.
1947 If test suites call this ``failure'', they should be run with the GCC
1948 option @option{-pedantic-errors}, which will turn these warnings into
1949 errors.
1950
1951 @end itemize
1952
1953 @node Warnings and Errors
1954 @section Warning Messages and Error Messages
1955
1956 @cindex error messages
1957 @cindex warnings vs errors
1958 @cindex messages, warning and error
1959 The GNU compiler can produce two kinds of diagnostics: errors and
1960 warnings.  Each kind has a different purpose:
1961
1962 @itemize @w{}
1963 @item
1964 @dfn{Errors} report problems that make it impossible to compile your
1965 program.  GCC reports errors with the source file name and line
1966 number where the problem is apparent.
1967
1968 @item
1969 @dfn{Warnings} report other unusual conditions in your code that
1970 @emph{may} indicate a problem, although compilation can (and does)
1971 proceed.  Warning messages also report the source file name and line
1972 number, but include the text @samp{warning:} to distinguish them
1973 from error messages.
1974 @end itemize
1975
1976 Warnings may indicate danger points where you should check to make sure
1977 that your program really does what you intend; or the use of obsolete
1978 features; or the use of nonstandard features of GNU C or C++.  Many
1979 warnings are issued only if you ask for them, with one of the @option{-W}
1980 options (for instance, @option{-Wall} requests a variety of useful
1981 warnings).
1982
1983 @opindex pedantic
1984 @opindex pedantic-errors
1985 GCC always tries to compile your program if possible; it never
1986 gratuitously rejects a program whose meaning is clear merely because
1987 (for instance) it fails to conform to a standard.  In some cases,
1988 however, the C and C++ standards specify that certain extensions are
1989 forbidden, and a diagnostic @emph{must} be issued by a conforming
1990 compiler.  The @option{-pedantic} option tells GCC to issue warnings in
1991 such cases; @option{-pedantic-errors} says to make them errors instead.
1992 This does not mean that @emph{all} non-ISO constructs get warnings
1993 or errors.
1994
1995 @xref{Warning Options,,Options to Request or Suppress Warnings}, for
1996 more detail on these and related command-line options.
1997
1998 @node Bugs
1999 @chapter Reporting Bugs
2000 @cindex bugs
2001 @cindex reporting bugs
2002
2003 Your bug reports play an essential role in making GCC reliable.
2004
2005 When you encounter a problem, the first thing to do is to see if it is
2006 already known.  @xref{Trouble}.  If it isn't known, then you should
2007 report the problem.
2008
2009 Reporting a bug may help you by bringing a solution to your problem, or
2010 it may not.  (If it does not, look in the service directory; see
2011 @ref{Service}.)  In any case, the principal function of a bug report is
2012 to help the entire community by making the next version of GCC work
2013 better.  Bug reports are your contribution to the maintenance of GCC.
2014
2015 Since the maintainers are very overloaded, we cannot respond to every
2016 bug report.  However, if the bug has not been fixed, we are likely to
2017 send you a patch and ask you to tell us whether it works.
2018
2019 In order for a bug report to serve its purpose, you must include the
2020 information that makes for fixing the bug.
2021
2022 @menu
2023 * Criteria:  Bug Criteria.   Have you really found a bug?
2024 * Where: Bug Lists.          Where to send your bug report.
2025 * Reporting: Bug Reporting.  How to report a bug effectively.
2026 * GNATS: gccbug.             You can use a bug reporting tool.
2027 * Patches: Sending Patches.  How to send a patch for GCC.
2028 * Known: Trouble.            Known problems.
2029 * Help: Service.             Where to ask for help.
2030 @end menu
2031
2032 @node Bug Criteria,Bug Lists,,Bugs
2033 @section Have You Found a Bug?
2034 @cindex bug criteria
2035
2036 If you are not sure whether you have found a bug, here are some guidelines:
2037
2038 @itemize @bullet
2039 @cindex fatal signal
2040 @cindex core dump
2041 @item
2042 If the compiler gets a fatal signal, for any input whatever, that is a
2043 compiler bug.  Reliable compilers never crash.
2044
2045 @cindex invalid assembly code
2046 @cindex assembly code, invalid
2047 @item
2048 If the compiler produces invalid assembly code, for any input whatever
2049 (except an @code{asm} statement), that is a compiler bug, unless the
2050 compiler reports errors (not just warnings) which would ordinarily
2051 prevent the assembler from being run.
2052
2053 @cindex undefined behavior
2054 @cindex undefined function value
2055 @cindex increment operators
2056 @item
2057 If the compiler produces valid assembly code that does not correctly
2058 execute the input source code, that is a compiler bug.
2059
2060 However, you must double-check to make sure, because you may have run
2061 into an incompatibility between GNU C and traditional C
2062 (@pxref{Incompatibilities}).  These incompatibilities might be considered
2063 bugs, but they are inescapable consequences of valuable features.
2064
2065 Or you may have a program whose behavior is undefined, which happened
2066 by chance to give the desired results with another C or C++ compiler.
2067
2068 For example, in many nonoptimizing compilers, you can write @samp{x;}
2069 at the end of a function instead of @samp{return x;}, with the same
2070 results.  But the value of the function is undefined if @code{return}
2071 is omitted; it is not a bug when GCC produces different results.
2072
2073 Problems often result from expressions with two increment operators,
2074 as in @code{f (*p++, *p++)}.  Your previous compiler might have
2075 interpreted that expression the way you intended; GCC might
2076 interpret it another way.  Neither compiler is wrong.  The bug is
2077 in your code.
2078
2079 After you have localized the error to a single source line, it should
2080 be easy to check for these things.  If your program is correct and
2081 well defined, you have found a compiler bug.
2082
2083 @item
2084 If the compiler produces an error message for valid input, that is a
2085 compiler bug.
2086
2087 @cindex invalid input
2088 @item
2089 If the compiler does not produce an error message for invalid input,
2090 that is a compiler bug.  However, you should note that your idea of
2091 ``invalid input'' might be my idea of ``an extension'' or ``support
2092 for traditional practice''.
2093
2094 @item
2095 If you are an experienced user of one of the languages GCC supports, your
2096 suggestions for improvement of GCC are welcome in any case.
2097 @end itemize
2098
2099 @node Bug Lists,Bug Reporting,Bug Criteria,Bugs
2100 @section Where to Report Bugs
2101 @cindex bug report mailing lists
2102 @kindex gcc-bugs@@gcc.gnu.org or bug-gcc@@gnu.org
2103 Send bug reports for the GNU Compiler Collection to
2104 @email{gcc-bugs@@gcc.gnu.org}.  In accordance with the GNU-wide
2105 convention, in which bug reports for tool ``foo'' are sent
2106 to @samp{bug-foo@@gnu.org}, the address @email{bug-gcc@@gnu.org}
2107 may also be used; it will forward to the address given above.
2108
2109 Please read @uref{http://gcc.gnu.org/bugs.html} for additional and/or
2110 more up-to-date bug reporting instructions before you post a bug report.
2111
2112 @node Bug Reporting,gccbug,Bug Lists,Bugs
2113 @section How to Report Bugs
2114 @cindex compiler bugs, reporting
2115
2116 The fundamental principle of reporting bugs usefully is this:
2117 @strong{report all the facts}.  If you are not sure whether to state a
2118 fact or leave it out, state it!
2119
2120 Often people omit facts because they think they know what causes the
2121 problem and they conclude that some details don't matter.  Thus, you might
2122 assume that the name of the variable you use in an example does not matter.
2123 Well, probably it doesn't, but one cannot be sure.  Perhaps the bug is a
2124 stray memory reference which happens to fetch from the location where that
2125 name is stored in memory; perhaps, if the name were different, the contents
2126 of that location would fool the compiler into doing the right thing despite
2127 the bug.  Play it safe and give a specific, complete example.  That is the
2128 easiest thing for you to do, and the most helpful.
2129
2130 Keep in mind that the purpose of a bug report is to enable someone to
2131 fix the bug if it is not known.  It isn't very important what happens if
2132 the bug is already known.  Therefore, always write your bug reports on
2133 the assumption that the bug is not known.
2134
2135 Sometimes people give a few sketchy facts and ask, ``Does this ring a
2136 bell?''  This cannot help us fix a bug, so it is basically useless.  We
2137 respond by asking for enough details to enable us to investigate.
2138 You might as well expedite matters by sending them to begin with.
2139
2140 Try to make your bug report self-contained.  If we have to ask you for
2141 more information, it is best if you include all the previous information
2142 in your response, as well as the information that was missing.
2143
2144 Please report each bug in a separate message.  This makes it easier for
2145 us to track which bugs have been fixed and to forward your bugs reports
2146 to the appropriate maintainer.
2147
2148 To enable someone to investigate the bug, you should include all these
2149 things:
2150
2151 @itemize @bullet
2152 @item
2153 The version of GCC.  You can get this by running it with the
2154 @option{-v} option.
2155
2156 Without this, we won't know whether there is any point in looking for
2157 the bug in the current version of GCC.
2158
2159 @item
2160 A complete input file that will reproduce the bug.  If the bug is in the
2161 C preprocessor, send a source file and any header files that it
2162 requires.  If the bug is in the compiler proper (@file{cc1}), send the
2163 preprocessor output generated by adding @option{-save-temps} to the
2164 compilation command (@pxref{Debugging Options}).  When you do this, use
2165 the same @option{-I}, @option{-D} or @option{-U} options that you used in
2166 actual compilation. Then send the @var{input}.i or @var{input}.ii files
2167 generated.
2168
2169 A single statement is not enough of an example.  In order to compile it,
2170 it must be embedded in a complete file of compiler input; and the bug
2171 might depend on the details of how this is done.
2172
2173 Without a real example one can compile, all anyone can do about your bug
2174 report is wish you luck.  It would be futile to try to guess how to
2175 provoke the bug.  For example, bugs in register allocation and reloading
2176 frequently depend on every little detail of the function they happen in.
2177
2178 Even if the input file that fails comes from a GNU program, you should
2179 still send the complete test case.  Don't ask the GCC maintainers to
2180 do the extra work of obtaining the program in question---they are all
2181 overworked as it is.  Also, the problem may depend on what is in the
2182 header files on your system; it is unreliable for the GCC maintainers
2183 to try the problem with the header files available to them.  By sending
2184 CPP output, you can eliminate this source of uncertainty and save us
2185 a certain percentage of wild goose chases.
2186
2187 @item
2188 The command arguments you gave GCC to compile that example
2189 and observe the bug.  For example, did you use @option{-O}?  To guarantee
2190 you won't omit something important, list all the options.
2191
2192 If we were to try to guess the arguments, we would probably guess wrong
2193 and then we would not encounter the bug.
2194
2195 @item
2196 The type of machine you are using, and the operating system name and
2197 version number.
2198
2199 @item
2200 The operands you gave to the @code{configure} command when you installed
2201 the compiler.
2202
2203 @item
2204 A complete list of any modifications you have made to the compiler
2205 source.  (We don't promise to investigate the bug unless it happens in
2206 an unmodified compiler.  But if you've made modifications and don't tell
2207 us, then you are sending us on a wild goose chase.)
2208
2209 Be precise about these changes.  A description in English is not
2210 enough---send a context diff for them.
2211
2212 Adding files of your own (such as a machine description for a machine we
2213 don't support) is a modification of the compiler source.
2214
2215 @item
2216 Details of any other deviations from the standard procedure for installing
2217 GCC.
2218
2219 @item
2220 A description of what behavior you observe that you believe is
2221 incorrect.  For example, ``The compiler gets a fatal signal,'' or,
2222 ``The assembler instruction at line 208 in the output is incorrect.''
2223
2224 Of course, if the bug is that the compiler gets a fatal signal, then one
2225 can't miss it.  But if the bug is incorrect output, the maintainer might
2226 not notice unless it is glaringly wrong.  None of us has time to study
2227 all the assembler code from a 50-line C program just on the chance that
2228 one instruction might be wrong.  We need @emph{you} to do this part!
2229
2230 Even if the problem you experience is a fatal signal, you should still
2231 say so explicitly.  Suppose something strange is going on, such as, your
2232 copy of the compiler is out of synch, or you have encountered a bug in
2233 the C library on your system.  (This has happened!)  Your copy might
2234 crash and the copy here would not.  If you @i{said} to expect a crash,
2235 then when the compiler here fails to crash, we would know that the bug
2236 was not happening.  If you don't say to expect a crash, then we would
2237 not know whether the bug was happening.  We would not be able to draw
2238 any conclusion from our observations.
2239
2240 If the problem is a diagnostic when compiling GCC with some other
2241 compiler, say whether it is a warning or an error.
2242
2243 Often the observed symptom is incorrect output when your program is run.
2244 Sad to say, this is not enough information unless the program is short
2245 and simple.  None of us has time to study a large program to figure out
2246 how it would work if compiled correctly, much less which line of it was
2247 compiled wrong.  So you will have to do that.  Tell us which source line
2248 it is, and what incorrect result happens when that line is executed.  A
2249 person who understands the program can find this as easily as finding a
2250 bug in the program itself.
2251
2252 @item
2253 If you send examples of assembler code output from GCC,
2254 please use @option{-g} when you make them.  The debugging information
2255 includes source line numbers which are essential for correlating the
2256 output with the input.
2257
2258 @item
2259 If you wish to mention something in the GCC source, refer to it by
2260 context, not by line number.
2261
2262 The line numbers in the development sources don't match those in your
2263 sources.  Your line numbers would convey no useful information to the
2264 maintainers.
2265
2266 @item
2267 Additional information from a debugger might enable someone to find a
2268 problem on a machine which he does not have available.  However, you
2269 need to think when you collect this information if you want it to have
2270 any chance of being useful.
2271
2272 @cindex backtrace for bug reports
2273 For example, many people send just a backtrace, but that is never
2274 useful by itself.  A simple backtrace with arguments conveys little
2275 about GCC because the compiler is largely data-driven; the same
2276 functions are called over and over for different RTL insns, doing
2277 different things depending on the details of the insn.
2278
2279 Most of the arguments listed in the backtrace are useless because they
2280 are pointers to RTL list structure.  The numeric values of the
2281 pointers, which the debugger prints in the backtrace, have no
2282 significance whatever; all that matters is the contents of the objects
2283 they point to (and most of the contents are other such pointers).
2284
2285 In addition, most compiler passes consist of one or more loops that
2286 scan the RTL insn sequence.  The most vital piece of information about
2287 such a loop---which insn it has reached---is usually in a local variable,
2288 not in an argument.
2289
2290 @findex debug_rtx
2291 What you need to provide in addition to a backtrace are the values of
2292 the local variables for several stack frames up.  When a local
2293 variable or an argument is an RTX, first print its value and then use
2294 the GDB command @code{pr} to print the RTL expression that it points
2295 to.  (If GDB doesn't run on your machine, use your debugger to call
2296 the function @code{debug_rtx} with the RTX as an argument.)  In
2297 general, whenever a variable is a pointer, its value is no use
2298 without the data it points to.
2299 @end itemize
2300
2301 Here are some things that are not necessary:
2302
2303 @itemize @bullet
2304 @item
2305 A description of the envelope of the bug.
2306
2307 Often people who encounter a bug spend a lot of time investigating
2308 which changes to the input file will make the bug go away and which
2309 changes will not affect it.
2310
2311 This is often time consuming and not very useful, because the way we
2312 will find the bug is by running a single example under the debugger with
2313 breakpoints, not by pure deduction from a series of examples.  You might
2314 as well save your time for something else.
2315
2316 Of course, if you can find a simpler example to report @emph{instead} of
2317 the original one, that is a convenience.  Errors in the output will be
2318 easier to spot, running under the debugger will take less time, etc.
2319 Most GCC bugs involve just one function, so the most straightforward
2320 way to simplify an example is to delete all the function definitions
2321 except the one where the bug occurs.  Those earlier in the file may be
2322 replaced by external declarations if the crucial function depends on
2323 them.  (Exception: inline functions may affect compilation of functions
2324 defined later in the file.)
2325
2326 However, simplification is not vital; if you don't want to do this,
2327 report the bug anyway and send the entire test case you used.
2328
2329 @item
2330 In particular, some people insert conditionals @samp{#ifdef BUG} around
2331 a statement which, if removed, makes the bug not happen.  These are just
2332 clutter; we won't pay any attention to them anyway.  Besides, you should
2333 send us cpp output, and that can't have conditionals.
2334
2335 @item
2336 A patch for the bug.
2337
2338 A patch for the bug is useful if it is a good one.  But don't omit the
2339 necessary information, such as the test case, on the assumption that a
2340 patch is all we need.  We might see problems with your patch and decide
2341 to fix the problem another way, or we might not understand it at all.
2342
2343 Sometimes with a program as complicated as GCC it is very hard to
2344 construct an example that will make the program follow a certain path
2345 through the code.  If you don't send the example, we won't be able to
2346 construct one, so we won't be able to verify that the bug is fixed.
2347
2348 And if we can't understand what bug you are trying to fix, or why your
2349 patch should be an improvement, we won't install it.  A test case will
2350 help us to understand.
2351
2352 @xref{Sending Patches}, for guidelines on how to make it easy for us to
2353 understand and install your patches.
2354
2355 @item
2356 A guess about what the bug is or what it depends on.
2357
2358 Such guesses are usually wrong.  Even I can't guess right about such
2359 things without first using the debugger to find the facts.
2360
2361 @item
2362 A core dump file.
2363
2364 We have no way of examining a core dump for your type of machine
2365 unless we have an identical system---and if we do have one,
2366 we should be able to reproduce the crash ourselves.
2367 @end itemize
2368
2369 @node gccbug,Sending Patches, Bug Reporting, Bugs
2370 @section The gccbug script
2371 @cindex gccbug script
2372
2373 To simplify creation of bug reports, and to allow better tracking of
2374 reports, we use the GNATS bug tracking system. Part of that system is
2375 the @code{gccbug} script. This is a Unix shell script, so you need a
2376 shell to run it. It is normally installed in the same directory where
2377 @code{gcc} is installed.
2378
2379 The gccbug script is derived from send-pr, @pxref{using
2380 send-pr,,Creating new Problem Reports,send-pr,Reporting Problems}. When
2381 invoked, it starts a text editor so you can fill out the various fields
2382 of the report. When the you quit the editor, the report is automatically
2383 send to the bug reporting address.
2384
2385 A number of fields in this bug report form are specific to GCC, and are
2386 explained at @uref{http://gcc.gnu.org/gnats.html}.
2387
2388 @node Sending Patches,, gccbug, Bugs
2389 @section Sending Patches for GCC
2390
2391 If you would like to write bug fixes or improvements for the GNU C
2392 compiler, that is very helpful.  Send suggested fixes to the patches
2393 mailing list, @email{gcc-patches@@gcc.gnu.org}.
2394
2395 Please follow these guidelines so we can study your patches efficiently.
2396 If you don't follow these guidelines, your information might still be
2397 useful, but using it will take extra work.  Maintaining GNU C is a lot
2398 of work in the best of circumstances, and we can't keep up unless you do
2399 your best to help.
2400
2401 @itemize @bullet
2402 @item
2403 Send an explanation with your changes of what problem they fix or what
2404 improvement they bring about.  For a bug fix, just include a copy of the
2405 bug report, and explain why the change fixes the bug.
2406
2407 (Referring to a bug report is not as good as including it, because then
2408 we will have to look it up, and we have probably already deleted it if
2409 we've already fixed the bug.)
2410
2411 @item
2412 Always include a proper bug report for the problem you think you have
2413 fixed.  We need to convince ourselves that the change is right before
2414 installing it.  Even if it is right, we might have trouble judging it if
2415 we don't have a way to reproduce the problem.
2416
2417 @item
2418 Include all the comments that are appropriate to help people reading the
2419 source in the future understand why this change was needed.
2420
2421 @item
2422 Don't mix together changes made for different reasons.
2423 Send them @emph{individually}.
2424
2425 If you make two changes for separate reasons, then we might not want to
2426 install them both.  We might want to install just one.  If you send them
2427 all jumbled together in a single set of diffs, we have to do extra work
2428 to disentangle them---to figure out which parts of the change serve
2429 which purpose.  If we don't have time for this, we might have to ignore
2430 your changes entirely.
2431
2432 If you send each change as soon as you have written it, with its own
2433 explanation, then the two changes never get tangled up, and we can
2434 consider each one properly without any extra work to disentangle them.
2435
2436 Ideally, each change you send should be impossible to subdivide into
2437 parts that we might want to consider separately, because each of its
2438 parts gets its motivation from the other parts.
2439
2440 @item
2441 Send each change as soon as that change is finished.  Sometimes people
2442 think they are helping us by accumulating many changes to send them all
2443 together.  As explained above, this is absolutely the worst thing you
2444 could do.
2445
2446 Since you should send each change separately, you might as well send it
2447 right away.  That gives us the option of installing it immediately if it
2448 is important.
2449
2450 @item
2451 Use @samp{diff -c} to make your diffs.  Diffs without context are hard
2452 for us to install reliably.  More than that, they make it hard for us to
2453 study the diffs to decide whether we want to install them.  Unidiff
2454 format is better than contextless diffs, but not as easy to read as
2455 @option{-c} format.
2456
2457 If you have GNU diff, use @samp{diff -cp}, which shows the name of the
2458 function that each change occurs in.
2459
2460 @item
2461 Write the change log entries for your changes.  We get lots of changes,
2462 and we don't have time to do all the change log writing ourselves.
2463
2464 Read the @file{ChangeLog} file to see what sorts of information to put
2465 in, and to learn the style that we use.  The purpose of the change log
2466 is to show people where to find what was changed.  So you need to be
2467 specific about what functions you changed; in large functions, it's
2468 often helpful to indicate where within the function the change was.
2469
2470 On the other hand, once you have shown people where to find the change,
2471 you need not explain its purpose.  Thus, if you add a new function, all
2472 you need to say about it is that it is new.  If you feel that the
2473 purpose needs explaining, it probably does---but the explanation will be
2474 much more useful if you put it in comments in the code.
2475
2476 If you would like your name to appear in the header line for who made
2477 the change, send us the header line.
2478
2479 @item
2480 When you write the fix, keep in mind that we can't install a change that
2481 would break other systems.
2482
2483 People often suggest fixing a problem by changing machine-independent
2484 files such as @file{toplev.c} to do something special that a particular
2485 system needs.  Sometimes it is totally obvious that such changes would
2486 break GCC for almost all users.  We can't possibly make a change like
2487 that.  At best it might tell us how to write another patch that would
2488 solve the problem acceptably.
2489
2490 Sometimes people send fixes that @emph{might} be an improvement in
2491 general---but it is hard to be sure of this.  It's hard to install
2492 such changes because we have to study them very carefully.  Of course,
2493 a good explanation of the reasoning by which you concluded the change
2494 was correct can help convince us.
2495
2496 The safest changes are changes to the configuration files for a
2497 particular machine.  These are safe because they can't create new bugs
2498 on other machines.
2499
2500 Please help us keep up with the workload by designing the patch in a
2501 form that is good to install.
2502 @end itemize
2503
2504 @node Service
2505 @chapter How To Get Help with GCC
2506
2507 If you need help installing, using or changing GCC, there are two
2508 ways to find it:
2509
2510 @itemize @bullet
2511 @item
2512 Send a message to a suitable network mailing list.  First try
2513 @email{gcc-help@@gcc.gnu.org} (for help installing or using GCC), and if
2514 that brings no response, try @email{gcc@@gcc.gnu.org}.  For help
2515 changing GCC, ask @email{gcc@@gcc.gnu.org}.  If you think you have found
2516 a bug in GCC, please report it following the instructions at
2517 @pxref{Bug Reporting}.
2518
2519 @item
2520 Look in the service directory for someone who might help you for a fee.
2521 The service directory is found at
2522 @uref{http://www.gnu.org/prep/service.html}.
2523 @end itemize
2524
2525 @c For further information, see
2526 @c @uref{http://gcc.gnu.org/cgi-bin/fom.cgi?file=12}.
2527 @c FIXME: this URL may be too volatile, this FAQ entry needs to move to
2528 @c the regular web pages before we can uncomment the reference.
2529
2530 @node Contributing
2531 @chapter Contributing to GCC Development
2532
2533 If you would like to help pretest GCC releases to assure they work well,
2534 our current development sources are available by CVS (see
2535 @uref{http://gcc.gnu.org/cvs.html}).  Source and binary snapshots are
2536 also available for FTP; see @uref{http://gcc.gnu.org/snapshots.html}.
2537
2538 If you would like to work on improvements to GCC, please read
2539 @uref{http://gcc.gnu.org/contribute.html} and
2540 @uref{http://gcc.gnu.org/contributewhy.html} for information on how to
2541 make useful contributions and avoid duplication of effort.  Suggested
2542 projects are listed at @uref{http://gcc.gnu.org/projects/}.
2543
2544 @node VMS
2545 @chapter Using GCC on VMS
2546
2547 @c prevent bad page break with this line
2548 Here is how to use GCC on VMS.
2549
2550 @menu
2551 * Include Files and VMS::  Where the preprocessor looks for the include files.
2552 * Global Declarations::    How to do globaldef, globalref and globalvalue with
2553                            GCC.
2554 * VMS Misc::               Misc information.
2555 @end menu
2556
2557 @node Include Files and VMS
2558 @section Include Files and VMS
2559
2560 @cindex include files and VMS
2561 @cindex VMS and include files
2562 @cindex header files and VMS
2563 Due to the differences between the filesystems of Unix and VMS, GCC
2564 attempts to translate file names in @samp{#include} into names that VMS
2565 will understand.  The basic strategy is to prepend a prefix to the
2566 specification of the include file, convert the whole filename to a VMS
2567 filename, and then try to open the file.  GCC tries various prefixes
2568 one by one until one of them succeeds:
2569
2570 @enumerate
2571 @item
2572 The first prefix is the @samp{GNU_CC_INCLUDE:} logical name: this is
2573 where GNU C header files are traditionally stored.  If you wish to store
2574 header files in non-standard locations, then you can assign the logical
2575 @samp{GNU_CC_INCLUDE} to be a search list, where each element of the
2576 list is suitable for use with a rooted logical.
2577
2578 @item
2579 The next prefix tried is @samp{SYS$SYSROOT:[SYSLIB.]}.  This is where
2580 VAX-C header files are traditionally stored.
2581
2582 @item
2583 If the include file specification by itself is a valid VMS filename, the
2584 preprocessor then uses this name with no prefix in an attempt to open
2585 the include file.
2586
2587 @item
2588 If the file specification is not a valid VMS filename (i.e. does not
2589 contain a device or a directory specifier, and contains a @samp{/}
2590 character), the preprocessor tries to convert it from Unix syntax to
2591 VMS syntax.
2592
2593 Conversion works like this: the first directory name becomes a device,
2594 and the rest of the directories are converted into VMS-format directory
2595 names.  For example, the name @file{X11/foobar.h} is
2596 translated to @file{X11:[000000]foobar.h} or @file{X11:foobar.h},
2597 whichever one can be opened.  This strategy allows you to assign a
2598 logical name to point to the actual location of the header files.
2599
2600 @item
2601 If none of these strategies succeeds, the @samp{#include} fails.
2602 @end enumerate
2603
2604 Include directives of the form:
2605
2606 @example
2607 #include foobar
2608 @end example
2609
2610 @noindent
2611 are a common source of incompatibility between VAX-C and GCC.  VAX-C
2612 treats this much like a standard @code{#include <foobar.h>} directive.
2613 That is incompatible with the ISO C behavior implemented by GCC: to
2614 expand the name @code{foobar} as a macro.  Macro expansion should
2615 eventually yield one of the two standard formats for @code{#include}:
2616
2617 @example
2618 #include "@var{file}"
2619 #include <@var{file}>
2620 @end example
2621
2622 If you have this problem, the best solution is to modify the source to
2623 convert the @code{#include} directives to one of the two standard forms.
2624 That will work with either compiler.  If you want a quick and dirty fix,
2625 define the file names as macros with the proper expansion, like this:
2626
2627 @example
2628 #define stdio <stdio.h>
2629 @end example
2630
2631 @noindent
2632 This will work, as long as the name doesn't conflict with anything else
2633 in the program.
2634
2635 Another source of incompatibility is that VAX-C assumes that:
2636
2637 @example
2638 #include "foobar"
2639 @end example
2640
2641 @noindent
2642 is actually asking for the file @file{foobar.h}.  GCC does not
2643 make this assumption, and instead takes what you ask for literally;
2644 it tries to read the file @file{foobar}.  The best way to avoid this
2645 problem is to always specify the desired file extension in your include
2646 directives.
2647
2648 GCC for VMS is distributed with a set of include files that is
2649 sufficient to compile most general purpose programs.  Even though the
2650 GCC distribution does not contain header files to define constants
2651 and structures for some VMS system-specific functions, there is no
2652 reason why you cannot use GCC with any of these functions.  You first
2653 may have to generate or create header files, either by using the public
2654 domain utility @code{UNSDL} (which can be found on a DECUS tape), or by
2655 extracting the relevant modules from one of the system macro libraries,
2656 and using an editor to construct a C header file.
2657
2658 A @code{#include} file name cannot contain a DECNET node name.  The
2659 preprocessor reports an I/O error if you attempt to use a node name,
2660 whether explicitly, or implicitly via a logical name.
2661
2662 @node Global Declarations
2663 @section Global Declarations and VMS
2664
2665 @findex GLOBALREF
2666 @findex GLOBALDEF
2667 @findex GLOBALVALUEDEF
2668 @findex GLOBALVALUEREF
2669 GCC does not provide the @code{globalref}, @code{globaldef} and
2670 @code{globalvalue} keywords of VAX-C.  You can get the same effect with
2671 an obscure feature of GAS, the GNU assembler.  (This requires GAS
2672 version 1.39 or later.)  The following macros allow you to use this
2673 feature in a fairly natural way:
2674
2675 @smallexample
2676 #ifdef __GNUC__
2677 #define GLOBALREF(TYPE,NAME)                      \
2678   TYPE NAME                                       \
2679   asm ("_$$PsectAttributes_GLOBALSYMBOL$$" #NAME)
2680 #define GLOBALDEF(TYPE,NAME,VALUE)                \
2681   TYPE NAME                                       \
2682   asm ("_$$PsectAttributes_GLOBALSYMBOL$$" #NAME) \
2683     = VALUE
2684 #define GLOBALVALUEREF(TYPE,NAME)                 \
2685   const TYPE NAME[1]                              \
2686   asm ("_$$PsectAttributes_GLOBALVALUE$$" #NAME)
2687 #define GLOBALVALUEDEF(TYPE,NAME,VALUE)           \
2688   const TYPE NAME[1]                              \
2689   asm ("_$$PsectAttributes_GLOBALVALUE$$" #NAME)  \
2690     = @{VALUE@}
2691 #else
2692 #define GLOBALREF(TYPE,NAME) \
2693   globalref TYPE NAME
2694 #define GLOBALDEF(TYPE,NAME,VALUE) \
2695   globaldef TYPE NAME = VALUE
2696 #define GLOBALVALUEDEF(TYPE,NAME,VALUE) \
2697   globalvalue TYPE NAME = VALUE
2698 #define GLOBALVALUEREF(TYPE,NAME) \
2699   globalvalue TYPE NAME
2700 #endif
2701 @end smallexample
2702
2703 @noindent
2704 (The @code{_$$PsectAttributes_GLOBALSYMBOL} prefix at the start of the
2705 name is removed by the assembler, after it has modified the attributes
2706 of the symbol).  These macros are provided in the VMS binaries
2707 distribution in a header file @file{GNU_HACKS.H}.  An example of the
2708 usage is:
2709
2710 @example
2711 GLOBALREF (int, ijk);
2712 GLOBALDEF (int, jkl, 0);
2713 @end example
2714
2715 The macros @code{GLOBALREF} and @code{GLOBALDEF} cannot be used
2716 straightforwardly for arrays, since there is no way to insert the array
2717 dimension into the declaration at the right place.  However, you can
2718 declare an array with these macros if you first define a typedef for the
2719 array type, like this:
2720
2721 @example
2722 typedef int intvector[10];
2723 GLOBALREF (intvector, foo);
2724 @end example
2725
2726 Array and structure initializers will also break the macros; you can
2727 define the initializer to be a macro of its own, or you can expand the
2728 @code{GLOBALDEF} macro by hand.  You may find a case where you wish to
2729 use the @code{GLOBALDEF} macro with a large array, but you are not
2730 interested in explicitly initializing each element of the array.  In
2731 such cases you can use an initializer like: @code{@{0,@}}, which will
2732 initialize the entire array to @code{0}.
2733
2734 A shortcoming of this implementation is that a variable declared with
2735 @code{GLOBALVALUEREF} or @code{GLOBALVALUEDEF} is always an array.  For
2736 example, the declaration:
2737
2738 @example
2739 GLOBALVALUEREF(int, ijk);
2740 @end example
2741
2742 @noindent
2743 declares the variable @code{ijk} as an array of type @code{int [1]}.
2744 This is done because a globalvalue is actually a constant; its ``value''
2745 is what the linker would normally consider an address.  That is not how
2746 an integer value works in C, but it is how an array works.  So treating
2747 the symbol as an array name gives consistent results---with the
2748 exception that the value seems to have the wrong type.  @strong{Don't
2749 try to access an element of the array.}  It doesn't have any elements.
2750 The array ``address'' may not be the address of actual storage.
2751
2752 The fact that the symbol is an array may lead to warnings where the
2753 variable is used.  Insert type casts to avoid the warnings.  Here is an
2754 example; it takes advantage of the ISO C feature allowing macros that
2755 expand to use the same name as the macro itself.
2756
2757 @example
2758 GLOBALVALUEREF (int, ss$_normal);
2759 GLOBALVALUEDEF (int, xyzzy,123);
2760 #ifdef __GNUC__
2761 #define ss$_normal ((int) ss$_normal)
2762 #define xyzzy ((int) xyzzy)
2763 #endif
2764 @end example
2765
2766 Don't use @code{globaldef} or @code{globalref} with a variable whose
2767 type is an enumeration type; this is not implemented.  Instead, make the
2768 variable an integer, and use a @code{globalvaluedef} for each of the
2769 enumeration values.  An example of this would be:
2770
2771 @example
2772 #ifdef __GNUC__
2773 GLOBALDEF (int, color, 0);
2774 GLOBALVALUEDEF (int, RED, 0);
2775 GLOBALVALUEDEF (int, BLUE, 1);
2776 GLOBALVALUEDEF (int, GREEN, 3);
2777 #else
2778 enum globaldef color @{RED, BLUE, GREEN = 3@};
2779 #endif
2780 @end example
2781
2782 @node VMS Misc
2783 @section Other VMS Issues
2784
2785 @cindex exit status and VMS
2786 @cindex return value of @code{main}
2787 @cindex @code{main} and the exit status
2788 GCC automatically arranges for @code{main} to return 1 by default if
2789 you fail to specify an explicit return value.  This will be interpreted
2790 by VMS as a status code indicating a normal successful completion.
2791 Version 1 of GCC did not provide this default.
2792
2793 GCC on VMS works only with the GNU assembler, GAS.  You need version
2794 1.37 or later of GAS in order to produce value debugging information for
2795 the VMS debugger.  Use the ordinary VMS linker with the object files
2796 produced by GAS.
2797
2798 @cindex shared VMS run time system
2799 @cindex @file{VAXCRTL}
2800 Under previous versions of GCC, the generated code would occasionally
2801 give strange results when linked to the sharable @file{VAXCRTL} library.
2802 Now this should work.
2803
2804 A caveat for use of @code{const} global variables: the @code{const}
2805 modifier must be specified in every external declaration of the variable
2806 in all of the source files that use that variable.  Otherwise the linker
2807 will issue warnings about conflicting attributes for the variable.  Your
2808 program will still work despite the warnings, but the variable will be
2809 placed in writable storage.
2810
2811 @cindex name augmentation
2812 @cindex case sensitivity and VMS
2813 @cindex VMS and case sensitivity
2814 Although the VMS linker does distinguish between upper and lower case
2815 letters in global symbols, most VMS compilers convert all such symbols
2816 into upper case and most run-time library routines also have upper case
2817 names.  To be able to reliably call such routines, GCC (by means of
2818 the assembler GAS) converts global symbols into upper case like other
2819 VMS compilers.  However, since the usual practice in C is to distinguish
2820 case, GCC (via GAS) tries to preserve usual C behavior by augmenting
2821 each name that is not all lower case.  This means truncating the name
2822 to at most 23 characters and then adding more characters at the end
2823 which encode the case pattern of those 23.   Names which contain at
2824 least one dollar sign are an exception; they are converted directly into
2825 upper case without augmentation.
2826
2827 Name augmentation yields bad results for programs that use precompiled
2828 libraries (such as Xlib) which were generated by another compiler.  You
2829 can use the compiler option @samp{/NOCASE_HACK} to inhibit augmentation;
2830 it makes external C functions and variables case-independent as is usual
2831 on VMS.  Alternatively, you could write all references to the functions
2832 and variables in such libraries using lower case; this will work on VMS,
2833 but is not portable to other systems.  The compiler option @samp{/NAMES}
2834 also provides control over global name handling.
2835
2836 Function and variable names are handled somewhat differently with GNU
2837 C++.  The GNU C++ compiler performs @dfn{name mangling} on function
2838 names, which means that it adds information to the function name to
2839 describe the data types of the arguments that the function takes.  One
2840 result of this is that the name of a function can become very long.
2841 Since the VMS linker only recognizes the first 31 characters in a name,
2842 special action is taken to ensure that each function and variable has a
2843 unique name that can be represented in 31 characters.
2844
2845 If the name (plus a name augmentation, if required) is less than 32
2846 characters in length, then no special action is performed.  If the name
2847 is longer than 31 characters, the assembler (GAS) will generate a
2848 hash string based upon the function name, truncate the function name to
2849 23 characters, and append the hash string to the truncated name.  If the
2850 @samp{/VERBOSE} compiler option is used, the assembler will print both
2851 the full and truncated names of each symbol that is truncated.
2852
2853 The @samp{/NOCASE_HACK} compiler option should not be used when you are
2854 compiling programs that use libg++.  libg++ has several instances of
2855 objects (i.e.  @code{Filebuf} and @code{filebuf}) which become
2856 indistinguishable in a case-insensitive environment.  This leads to
2857 cases where you need to inhibit augmentation selectively (if you were
2858 using libg++ and Xlib in the same program, for example).  There is no
2859 special feature for doing this, but you can get the result by defining a
2860 macro for each mixed case symbol for which you wish to inhibit
2861 augmentation.  The macro should expand into the lower case equivalent of
2862 itself.  For example:
2863
2864 @example
2865 #define StuDlyCapS studlycaps
2866 @end example
2867
2868 These macro definitions can be placed in a header file to minimize the
2869 number of changes to your source code.
2870
2871 @node Makefile
2872 @chapter Makefile Targets
2873 @cindex makefile targets
2874 @cindex targets, makefile
2875
2876 @table @code
2877 @item all
2878 This is the default target.  Depending on what your build/host/target
2879 configuration is, it coordinates all the things that need to be built.
2880
2881 @item doc
2882 Produce info-formatted documentation.  Also, @code{make dvi} is
2883 available for DVI-formatted documentation, and @code{make
2884 generated-manpages} to generate man pages.
2885
2886 @item mostlyclean
2887 Delete the files made while building the compiler.
2888
2889 @item clean
2890 That, and all the other files built by @code{make all}.
2891
2892 @item distclean
2893 That, and all the files created by @code{configure}.
2894
2895 @item extraclean
2896 That, and any temporary or intermediate files, like emacs backup files.
2897
2898 @item maintainer-clean
2899 Distclean plus any file that can be generated from other files.  Note
2900 that additional tools may be required beyond what is normally needed to
2901 build gcc.
2902
2903 @item install
2904 Installs gcc.
2905
2906 @item uninstall
2907 Deletes installed files.
2908
2909 @item check
2910 Run the testsuite.  This creates a @file{testsuite} subdirectory that
2911 has various @file{.sum} and @file{.log} files containing the results of
2912 the testing.  You can run subsets with, for example, @code{make check-gcc}.
2913 You can specify specific tests by setting RUNTESTFLAGS to be the name
2914 of the @file{.exp} file, optionally followed by (for some tests) an equals
2915 and a file wildcard, like:
2916
2917 @example
2918 make check-gcc RUNTESTFLAGS="execute.exp=19980413-*"
2919 @end example
2920
2921 Note that running the testsuite may require additional tools be
2922 installed, such as TCL or dejagnu.
2923
2924 @item bootstrap
2925 Builds gcc three times---once with the native compiler, once with the
2926 native-built compiler it just built, and once with the compiler it built
2927 the second time.  In theory, the last two should produce the same
2928 results, which @code{make compare} can check.  Each step of this process
2929 is called a ``stage'', and the results of each stage @var{N}
2930 (@var{N} = 1@dots{}3) are copied to a subdirectory @file{stage@var{N}/}.
2931
2932 @item bootstrap-lean
2933 Like @code{bootstrap}, except that the various stages are removed once
2934 they're no longer needed.  This saves disk space.
2935
2936 @item bubblestrap
2937 Once bootstrapped, this incrementally rebuilds each of the three stages,
2938 one at a time.  It does this by ``bubbling'' the stages up from their
2939 stubdirectories, rebuilding them, and copying them back to their
2940 subdirectories.  This will allow you to, for example, quickly rebuild a
2941 bootstrapped compiler after changing the sources, without having to do a
2942 full bootstrap.
2943
2944 @item quickstrap
2945 Rebuilds the most recently built stage.  Since each stage requires
2946 special invocation, using this target means you don't have to keep track
2947 of which stage you're on or what invocation that stage needs.
2948
2949 @item cleanstrap
2950 Removed everything (@code{make clean}) and rebuilds (@code{make bootstrap}).
2951
2952 @item stage@var{N} (@var{N} = 1@dots{}4)
2953 For each stage, moves the appropriate files to the @file{stage@var{N}}
2954 subdirectory.
2955
2956 @item unstage@var{N} (@var{N} = 1@dots{}4)
2957 Undoes the corresponding @code{stage@var{N}}.
2958
2959 @item restage@var{N} (@var{N} = 1@dots{}4)
2960 Undoes the corresponding @code{stage@var{N}} and rebuilds it with the
2961 appropriate flags.
2962
2963 @item compare
2964 Compares the results of stages 2 and 3.  This ensures that the compiler
2965 is running properly, since it should produce the same object files
2966 regardless of how it itself was compiled.
2967
2968 @end table
2969
2970 @end ifset
2971
2972 @ifset INTERNALS
2973 @node Portability
2974 @chapter GCC and Portability
2975 @cindex portability
2976 @cindex GCC and portability
2977
2978 The main goal of GCC was to make a good, fast compiler for machines in
2979 the class that the GNU system aims to run on: 32-bit machines that address
2980 8-bit bytes and have several general registers.  Elegance, theoretical
2981 power and simplicity are only secondary.
2982
2983 GCC gets most of the information about the target machine from a machine
2984 description which gives an algebraic formula for each of the machine's
2985 instructions.  This is a very clean way to describe the target.  But when
2986 the compiler needs information that is difficult to express in this
2987 fashion, I have not hesitated to define an ad-hoc parameter to the machine
2988 description.  The purpose of portability is to reduce the total work needed
2989 on the compiler; it was not of interest for its own sake.
2990
2991 @cindex endianness
2992 @cindex autoincrement addressing, availability
2993 @findex abort
2994 GCC does not contain machine dependent code, but it does contain code
2995 that depends on machine parameters such as endianness (whether the most
2996 significant byte has the highest or lowest address of the bytes in a word)
2997 and the availability of autoincrement addressing.  In the RTL-generation
2998 pass, it is often necessary to have multiple strategies for generating code
2999 for a particular kind of syntax tree, strategies that are usable for different
3000 combinations of parameters.  Often I have not tried to address all possible
3001 cases, but only the common ones or only the ones that I have encountered.
3002 As a result, a new target may require additional strategies.  You will know
3003 if this happens because the compiler will call @code{abort}.  Fortunately,
3004 the new strategies can be added in a machine-independent fashion, and will
3005 affect only the target machines that need them.
3006 @end ifset
3007
3008 @ifset INTERNALS
3009 @node Interface
3010 @chapter Interfacing to GCC Output
3011 @cindex interfacing to GCC output
3012 @cindex run-time conventions
3013 @cindex function call conventions
3014 @cindex conventions, run-time
3015
3016 GCC is normally configured to use the same function calling convention
3017 normally in use on the target system.  This is done with the
3018 machine-description macros described (@pxref{Target Macros}).
3019
3020 @cindex unions, returning
3021 @cindex structures, returning
3022 @cindex returning structures and unions
3023 However, returning of structure and union values is done differently on
3024 some target machines.  As a result, functions compiled with PCC
3025 returning such types cannot be called from code compiled with GCC,
3026 and vice versa.  This does not cause trouble often because few Unix
3027 library routines return structures or unions.
3028
3029 GCC code returns structures and unions that are 1, 2, 4 or 8 bytes
3030 long in the same registers used for @code{int} or @code{double} return
3031 values.  (GCC typically allocates variables of such types in
3032 registers also.)  Structures and unions of other sizes are returned by
3033 storing them into an address passed by the caller (usually in a
3034 register).  The machine-description macros @code{STRUCT_VALUE} and
3035 @code{STRUCT_INCOMING_VALUE} tell GCC where to pass this address.
3036
3037 By contrast, PCC on most target machines returns structures and unions
3038 of any size by copying the data into an area of static storage, and then
3039 returning the address of that storage as if it were a pointer value.
3040 The caller must copy the data from that memory area to the place where
3041 the value is wanted.  This is slower than the method used by GCC, and
3042 fails to be reentrant.
3043
3044 On some target machines, such as RISC machines and the 80386, the
3045 standard system convention is to pass to the subroutine the address of
3046 where to return the value.  On these machines, GCC has been
3047 configured to be compatible with the standard compiler, when this method
3048 is used.  It may not be compatible for structures of 1, 2, 4 or 8 bytes.
3049
3050 @cindex argument passing
3051 @cindex passing arguments
3052 GCC uses the system's standard convention for passing arguments.  On
3053 some machines, the first few arguments are passed in registers; in
3054 others, all are passed on the stack.  It would be possible to use
3055 registers for argument passing on any machine, and this would probably
3056 result in a significant speedup.  But the result would be complete
3057 incompatibility with code that follows the standard convention.  So this
3058 change is practical only if you are switching to GCC as the sole C
3059 compiler for the system.  We may implement register argument passing on
3060 certain machines once we have a complete GNU system so that we can
3061 compile the libraries with GCC.
3062
3063 On some machines (particularly the Sparc), certain types of arguments
3064 are passed ``by invisible reference''.  This means that the value is
3065 stored in memory, and the address of the memory location is passed to
3066 the subroutine.
3067
3068 @cindex @code{longjmp} and automatic variables
3069 If you use @code{longjmp}, beware of automatic variables.  ISO C says that
3070 automatic variables that are not declared @code{volatile} have undefined
3071 values after a @code{longjmp}.  And this is all GCC promises to do,
3072 because it is very difficult to restore register variables correctly, and
3073 one of GCC's features is that it can put variables in registers without
3074 your asking it to.
3075
3076 If you want a variable to be unaltered by @code{longjmp}, and you don't
3077 want to write @code{volatile} because old C compilers don't accept it,
3078 just take the address of the variable.  If a variable's address is ever
3079 taken, even if just to compute it and ignore it, then the variable cannot
3080 go in a register:
3081
3082 @example
3083 @{
3084   int careful;
3085   &careful;
3086   @dots{}
3087 @}
3088 @end example
3089
3090 @cindex arithmetic libraries
3091 @cindex math libraries
3092 @opindex msoft-float
3093 Code compiled with GCC may call certain library routines.  Most of
3094 them handle arithmetic for which there are no instructions.  This
3095 includes multiply and divide on some machines, and floating point
3096 operations on any machine for which floating point support is disabled
3097 with @option{-msoft-float}.  Some standard parts of the C library, such as
3098 @code{bcopy} or @code{memcpy}, are also called automatically.  The usual
3099 function call interface is used for calling the library routines.
3100
3101 Some of these routines can be defined in mostly machine-independent C;
3102 they appear in @file{libgcc2.c}.  Others must be hand-written in
3103 assembly language for each processor.  Wherever they are defined, they
3104 are compiled into the support library, @file{libgcc.a}, which is
3105 automatically searched when you link programs with GCC.
3106 @end ifset
3107
3108 @ifset INTERNALS
3109 @node Passes
3110 @chapter Passes and Files of the Compiler
3111 @cindex passes and files of the compiler
3112 @cindex files and passes of the compiler
3113 @cindex compiler passes and files
3114
3115 @cindex top level of compiler
3116 The overall control structure of the compiler is in @file{toplev.c}.  This
3117 file is responsible for initialization, decoding arguments, opening and
3118 closing files, and sequencing the passes.
3119
3120 @cindex parsing pass
3121 The parsing pass is invoked only once, to parse the entire input.  The RTL
3122 intermediate code for a function is generated as the function is parsed, a
3123 statement at a time.  Each statement is read in as a syntax tree and then
3124 converted to RTL; then the storage for the tree for the statement is
3125 reclaimed.  Storage for types (and the expressions for their sizes),
3126 declarations, and a representation of the binding contours and how they nest,
3127 remain until the function is finished being compiled; these are all needed
3128 to output the debugging information.
3129
3130 @findex rest_of_compilation
3131 @findex rest_of_decl_compilation
3132 Each time the parsing pass reads a complete function definition or
3133 top-level declaration, it calls either the function
3134 @code{rest_of_compilation}, or the function
3135 @code{rest_of_decl_compilation} in @file{toplev.c}, which are
3136 responsible for all further processing necessary, ending with output of
3137 the assembler language.  All other compiler passes run, in sequence,
3138 within @code{rest_of_compilation}.  When that function returns from
3139 compiling a function definition, the storage used for that function
3140 definition's compilation is entirely freed, unless it is an inline
3141 function
3142 @ifset USING
3143 (@pxref{Inline,,An Inline Function is As Fast As a Macro}).
3144 @end ifset
3145 @ifclear USING
3146 (@pxref{Inline,,An Inline Function is As Fast As a Macro,gcc.texi,Using GCC}).
3147 @end ifclear
3148
3149 Here is a list of all the passes of the compiler and their source files.
3150 Also included is a description of where debugging dumps can be requested
3151 with @option{-d} options.
3152
3153 @itemize @bullet
3154 @item
3155 Parsing.  This pass reads the entire text of a function definition,
3156 constructing partial syntax trees.  This and RTL generation are no longer
3157 truly separate passes (formerly they were), but it is easier to think
3158 of them as separate.
3159
3160 The tree representation does not entirely follow C syntax, because it is
3161 intended to support other languages as well.
3162
3163 Language-specific data type analysis is also done in this pass, and every
3164 tree node that represents an expression has a data type attached.
3165 Variables are represented as declaration nodes.
3166
3167 @cindex constant folding
3168 @cindex arithmetic simplifications
3169 @cindex simplifications, arithmetic
3170 Constant folding and some arithmetic simplifications are also done
3171 during this pass.
3172
3173 The language-independent source files for parsing are
3174 @file{stor-layout.c}, @file{fold-const.c}, and @file{tree.c}.
3175 There are also header files @file{tree.h} and @file{tree.def}
3176 which define the format of the tree representation.@refill
3177
3178 @c Avoiding overfull is tricky here.
3179 The source files to parse C are
3180 @file{c-parse.in},
3181 @file{c-decl.c},
3182 @file{c-typeck.c},
3183 @file{c-aux-info.c},
3184 @file{c-convert.c},
3185 and @file{c-lang.c}
3186 along with header files
3187 @file{c-lex.h}, and
3188 @file{c-tree.h}.
3189
3190 The source files for parsing C++ are in @file{cp/}.
3191 They are @file{parse.y},
3192 @file{class.c},@*
3193 @file{cvt.c}, @file{decl.c}, @file{decl2.c},
3194 @file{except.c},@*
3195 @file{expr.c}, @file{init.c}, @file{lex.c},
3196 @file{method.c}, @file{ptree.c},@*
3197 @file{search.c}, @file{tree.c},
3198 @file{typeck2.c}, and
3199 @file{typeck.c}, along with header files @file{cp-tree.def},
3200 @file{cp-tree.h}, and @file{decl.h}.
3201
3202 The special source files for parsing Objective C are in @file{objc/}.
3203 They are @file{objc-parse.y}, @file{objc-act.c}, @file{objc-tree.def}, and
3204 @file{objc-act.h}.  Certain C-specific files are used for this as
3205 well.
3206
3207 The file @file{c-common.c} is also used for all of the above languages.
3208
3209 @cindex RTL generation
3210 @item
3211 RTL generation.  This is the conversion of syntax tree into RTL code.
3212 It is actually done statement-by-statement during parsing, but for
3213 most purposes it can be thought of as a separate pass.
3214
3215 @cindex target-parameter-dependent code
3216 This is where the bulk of target-parameter-dependent code is found,
3217 since often it is necessary for strategies to apply only when certain
3218 standard kinds of instructions are available.  The purpose of named
3219 instruction patterns is to provide this information to the RTL
3220 generation pass.
3221
3222 @cindex tail recursion optimization
3223 Optimization is done in this pass for @code{if}-conditions that are
3224 comparisons, boolean operations or conditional expressions.  Tail
3225 recursion is detected at this time also.  Decisions are made about how
3226 best to arrange loops and how to output @code{switch} statements.
3227
3228 @c Avoiding overfull is tricky here.
3229 The source files for RTL generation include
3230 @file{stmt.c},
3231 @file{calls.c},
3232 @file{expr.c},
3233 @file{explow.c},
3234 @file{expmed.c},
3235 @file{function.c},
3236 @file{optabs.c}
3237 and @file{emit-rtl.c}.
3238 Also, the file
3239 @file{insn-emit.c}, generated from the machine description by the
3240 program @code{genemit}, is used in this pass.  The header file
3241 @file{expr.h} is used for communication within this pass.@refill
3242
3243 @findex genflags
3244 @findex gencodes
3245 The header files @file{insn-flags.h} and @file{insn-codes.h},
3246 generated from the machine description by the programs @code{genflags}
3247 and @code{gencodes}, tell this pass which standard names are available
3248 for use and which patterns correspond to them.@refill
3249
3250 Aside from debugging information output, none of the following passes
3251 refers to the tree structure representation of the function (only
3252 part of which is saved).
3253
3254 @cindex inline, automatic
3255 The decision of whether the function can and should be expanded inline
3256 in its subsequent callers is made at the end of rtl generation.  The
3257 function must meet certain criteria, currently related to the size of
3258 the function and the types and number of parameters it has.  Note that
3259 this function may contain loops, recursive calls to itself
3260 (tail-recursive functions can be inlined!), gotos, in short, all
3261 constructs supported by GCC.  The file @file{integrate.c} contains
3262 the code to save a function's rtl for later inlining and to inline that
3263 rtl when the function is called.  The header file @file{integrate.h}
3264 is also used for this purpose.
3265
3266 @opindex dr
3267 The option @option{-dr} causes a debugging dump of the RTL code after
3268 this pass.  This dump file's name is made by appending @samp{.rtl} to
3269 the input file name.
3270
3271 @cindex jump optimization
3272 @cindex unreachable code
3273 @cindex dead code
3274 @item
3275 Jump optimization.  This pass simplifies jumps to the following
3276 instruction, jumps across jumps, and jumps to jumps.  It deletes
3277 unreferenced labels and unreachable code, except that unreachable code
3278 that contains a loop is not recognized as unreachable in this pass.
3279 (Such loops are deleted later in the basic block analysis.)  It also
3280 converts some code originally written with jumps into sequences of
3281 instructions that directly set values from the results of comparisons,
3282 if the machine has such instructions.
3283
3284 Jump optimization is performed two or three times.  The first time is
3285 immediately following RTL generation.  The second time is after CSE,
3286 but only if CSE says repeated jump optimization is needed.  The
3287 last time is right before the final pass.  That time, cross-jumping
3288 and deletion of no-op move instructions are done together with the
3289 optimizations described above.
3290
3291 The source file of this pass is @file{jump.c}.
3292
3293 @opindex dj
3294 The option @option{-dj} causes a debugging dump of the RTL code after
3295 this pass is run for the first time.  This dump file's name is made by
3296 appending @samp{.jump} to the input file name.
3297
3298 @cindex register use analysis
3299 @item
3300 Register scan.  This pass finds the first and last use of each
3301 register, as a guide for common subexpression elimination.  Its source
3302 is in @file{regclass.c}.
3303
3304 @cindex jump threading
3305 @item
3306 @opindex fthread-jumps
3307 Jump threading.  This pass detects a condition jump that branches to an
3308 identical or inverse test.  Such jumps can be @samp{threaded} through
3309 the second conditional test.  The source code for this pass is in
3310 @file{jump.c}.  This optimization is only performed if
3311 @option{-fthread-jumps} is enabled.
3312
3313 @cindex common subexpression elimination
3314 @cindex constant propagation
3315 @item
3316 Common subexpression elimination.  This pass also does constant
3317 propagation.  Its source file is @file{cse.c}.  If constant
3318 propagation causes conditional jumps to become unconditional or to
3319 become no-ops, jump optimization is run again when CSE is finished.
3320
3321 @opindex ds
3322 The option @option{-ds} causes a debugging dump of the RTL code after
3323 this pass.  This dump file's name is made by appending @samp{.cse} to
3324 the input file name.
3325
3326 @cindex global common subexpression elimination
3327 @cindex constant propagation
3328 @cindex copy propagation
3329 @item
3330 Global common subexpression elimination.  This pass performs GCSE
3331 using Morel-Renvoise Partial Redundancy Elimination, with the exception
3332 that it does not try to move invariants out of loops---that is left to
3333 the loop optimization pass.  This pass also performs global constant
3334 and copy propagation.
3335
3336 The source file for this pass is gcse.c.
3337
3338 @opindex dG
3339 The option @option{-dG} causes a debugging dump of the RTL code after
3340 this pass.  This dump file's name is made by appending @samp{.gcse} to
3341 the input file name.
3342
3343 @cindex loop optimization
3344 @cindex code motion
3345 @cindex strength-reduction
3346 @item
3347 Loop optimization.  This pass moves constant expressions out of loops,
3348 and optionally does strength-reduction and loop unrolling as well.
3349 Its source files are @file{loop.c} and @file{unroll.c}, plus the header
3350 @file{loop.h} used for communication between them.  Loop unrolling uses
3351 some functions in @file{integrate.c} and the header @file{integrate.h}.
3352
3353 @opindex dL
3354 The option @option{-dL} causes a debugging dump of the RTL code after
3355 this pass.  This dump file's name is made by appending @samp{.loop} to
3356 the input file name.
3357
3358 @item
3359 @opindex frerun-cse-after-loop
3360 If @option{-frerun-cse-after-loop} was enabled, a second common
3361 subexpression elimination pass is performed after the loop optimization
3362 pass.  Jump threading is also done again at this time if it was specified.
3363
3364 @opindex dt
3365 The option @option{-dt} causes a debugging dump of the RTL code after
3366 this pass.  This dump file's name is made by appending @samp{.cse2} to
3367 the input file name.
3368
3369 @cindex data flow analysis
3370 @cindex analysis, data flow
3371 @cindex basic blocks
3372 @item
3373 Data flow analysis (@file{flow.c}).  This pass divides the program
3374 into basic blocks (and in the process deletes unreachable loops); then
3375 it computes which pseudo-registers are live at each point in the
3376 program, and makes the first instruction that uses a value point at
3377 the instruction that computed the value.
3378
3379 @cindex autoincrement/decrement analysis
3380 This pass also deletes computations whose results are never used, and
3381 combines memory references with add or subtract instructions to make
3382 autoincrement or autodecrement addressing.
3383
3384 @opindex df
3385 The option @option{-df} causes a debugging dump of the RTL code after
3386 this pass.  This dump file's name is made by appending @samp{.flow} to
3387 the input file name.  If stupid register allocation is in use, this
3388 dump file reflects the full results of such allocation.
3389
3390 @cindex instruction combination
3391 @item
3392 Instruction combination (@file{combine.c}).  This pass attempts to
3393 combine groups of two or three instructions that are related by data
3394 flow into single instructions.  It combines the RTL expressions for
3395 the instructions by substitution, simplifies the result using algebra,
3396 and then attempts to match the result against the machine description.
3397
3398 @opindex dc
3399 The option @option{-dc} causes a debugging dump of the RTL code after
3400 this pass.  This dump file's name is made by appending @samp{.combine}
3401 to the input file name.
3402
3403 @cindex register movement
3404 @item
3405 Register movement (@file{regmove.c}). This pass looks for cases where
3406 matching constraints would force an instruction to need a reload, and
3407 this reload would be a register to register move.  It then attempts
3408 to change the registers used by the instruction to avoid the move
3409 instruction.
3410
3411 @opindex dN
3412 The option @option{-dN} causes a debugging dump of the RTL code after
3413 this pass.  This dump file's name is made by appending @samp{.regmove}
3414 to the input file name.
3415
3416 @cindex instruction scheduling
3417 @cindex scheduling, instruction
3418 @item
3419 Instruction scheduling (@file{sched.c}).  This pass looks for
3420 instructions whose output will not be available by the time that it is
3421 used in subsequent instructions.  (Memory loads and floating point
3422 instructions often have this behavior on RISC machines).  It re-orders
3423 instructions within a basic block to try to separate the definition and
3424 use of items that otherwise would cause pipeline stalls.
3425
3426 Instruction scheduling is performed twice.  The first time is immediately
3427 after instruction combination and the second is immediately after reload.
3428
3429 @opindex dS
3430 The option @option{-dS} causes a debugging dump of the RTL code after this
3431 pass is run for the first time.  The dump file's name is made by
3432 appending @samp{.sched} to the input file name.
3433
3434 @cindex register class preference pass
3435 @item
3436 Register class preferencing.  The RTL code is scanned to find out
3437 which register class is best for each pseudo register.  The source
3438 file is @file{regclass.c}.
3439
3440 @cindex register allocation
3441 @cindex local register allocation
3442 @item
3443 Local register allocation (@file{local-alloc.c}).  This pass allocates
3444 hard registers to pseudo registers that are used only within one basic
3445 block.  Because the basic block is linear, it can use fast and
3446 powerful techniques to do a very good job.
3447
3448 @opindex dl
3449 The option @option{-dl} causes a debugging dump of the RTL code after
3450 this pass.  This dump file's name is made by appending @samp{.lreg} to
3451 the input file name.
3452
3453 @cindex global register allocation
3454 @item
3455 Global register allocation (@file{global.c}).  This pass
3456 allocates hard registers for the remaining pseudo registers (those
3457 whose life spans are not contained in one basic block).
3458
3459 @cindex reloading
3460 @item
3461 Reloading.  This pass renumbers pseudo registers with the hardware
3462 registers numbers they were allocated.  Pseudo registers that did not
3463 get hard registers are replaced with stack slots.  Then it finds
3464 instructions that are invalid because a value has failed to end up in
3465 a register, or has ended up in a register of the wrong kind.  It fixes
3466 up these instructions by reloading the problematical values
3467 temporarily into registers.  Additional instructions are generated to
3468 do the copying.
3469
3470 The reload pass also optionally eliminates the frame pointer and inserts
3471 instructions to save and restore call-clobbered registers around calls.
3472
3473 Source files are @file{reload.c} and @file{reload1.c}, plus the header
3474 @file{reload.h} used for communication between them.
3475
3476 @opindex dg
3477 The option @option{-dg} causes a debugging dump of the RTL code after
3478 this pass.  This dump file's name is made by appending @samp{.greg} to
3479 the input file name.
3480
3481 @cindex instruction scheduling
3482 @cindex scheduling, instruction
3483 @item
3484 Instruction scheduling is repeated here to try to avoid pipeline stalls
3485 due to memory loads generated for spilled pseudo registers.
3486
3487 @opindex dR
3488 The option @option{-dR} causes a debugging dump of the RTL code after
3489 this pass.  This dump file's name is made by appending @samp{.sched2}
3490 to the input file name.
3491
3492 @cindex cross-jumping
3493 @cindex no-op move instructions
3494 @item
3495 Jump optimization is repeated, this time including cross-jumping
3496 and deletion of no-op move instructions.
3497
3498 @opindex dJ
3499 The option @option{-dJ} causes a debugging dump of the RTL code after
3500 this pass.  This dump file's name is made by appending @samp{.jump2}
3501 to the input file name.
3502
3503 @cindex delayed branch scheduling
3504 @cindex scheduling, delayed branch
3505 @item
3506 Delayed branch scheduling.  This optional pass attempts to find
3507 instructions that can go into the delay slots of other instructions,
3508 usually jumps and calls.  The source file name is @file{reorg.c}.
3509
3510 @opindex dd
3511 The option @option{-dd} causes a debugging dump of the RTL code after
3512 this pass.  This dump file's name is made by appending @samp{.dbr}
3513 to the input file name.
3514
3515 @cindex branch shortening
3516 @item
3517 Branch shortening.  On many RISC machines, branch instructions have a
3518 limited range.  Thus, longer sequences of instructions must be used for
3519 long branches.  In this pass, the compiler figures out what how far each
3520 instruction will be from each other instruction, and therefore whether
3521 the usual instructions, or the longer sequences, must be used for each
3522 branch.
3523
3524 @cindex register-to-stack conversion
3525 @item
3526 Conversion from usage of some hard registers to usage of a register
3527 stack may be done at this point.  Currently, this is supported only
3528 for the floating-point registers of the Intel 80387 coprocessor.   The
3529 source file name is @file{reg-stack.c}.
3530
3531 @opindex dk
3532 The options @option{-dk} causes a debugging dump of the RTL code after
3533 this pass.  This dump file's name is made by appending @samp{.stack}
3534 to the input file name.
3535
3536 @cindex final pass
3537 @cindex peephole optimization
3538 @item
3539 Final.  This pass outputs the assembler code for the function.  It is
3540 also responsible for identifying spurious test and compare
3541 instructions.  Machine-specific peephole optimizations are performed
3542 at the same time.  The function entry and exit sequences are generated
3543 directly as assembler code in this pass; they never exist as RTL.
3544
3545 The source files are @file{final.c} plus @file{insn-output.c}; the
3546 latter is generated automatically from the machine description by the
3547 tool @file{genoutput}.  The header file @file{conditions.h} is used
3548 for communication between these files.
3549
3550 @cindex debugging information generation
3551 @item
3552 Debugging information output.  This is run after final because it must
3553 output the stack slot offsets for pseudo registers that did not get
3554 hard registers.  Source files are @file{dbxout.c} for DBX symbol table
3555 format, @file{sdbout.c} for SDB symbol table format, and
3556 @file{dwarfout.c} for DWARF symbol table format.
3557 @end itemize
3558
3559 Some additional files are used by all or many passes:
3560
3561 @itemize @bullet
3562 @item
3563 Every pass uses @file{machmode.def} and @file{machmode.h} which define
3564 the machine modes.
3565
3566 @item
3567 Several passes use @file{real.h}, which defines the default
3568 representation of floating point constants and how to operate on them.
3569
3570 @item
3571 All the passes that work with RTL use the header files @file{rtl.h}
3572 and @file{rtl.def}, and subroutines in file @file{rtl.c}.  The tools
3573 @code{gen*} also use these files to read and work with the machine
3574 description RTL.
3575
3576 @findex genconfig
3577 @item
3578 Several passes refer to the header file @file{insn-config.h} which
3579 contains a few parameters (C macro definitions) generated
3580 automatically from the machine description RTL by the tool
3581 @code{genconfig}.
3582
3583 @cindex instruction recognizer
3584 @item
3585 Several passes use the instruction recognizer, which consists of
3586 @file{recog.c} and @file{recog.h}, plus the files @file{insn-recog.c}
3587 and @file{insn-extract.c} that are generated automatically from the
3588 machine description by the tools @file{genrecog} and
3589 @file{genextract}.@refill
3590
3591 @item
3592 Several passes use the header files @file{regs.h} which defines the
3593 information recorded about pseudo register usage, and @file{basic-block.h}
3594 which defines the information recorded about basic blocks.
3595
3596 @item
3597 @file{hard-reg-set.h} defines the type @code{HARD_REG_SET}, a bit-vector
3598 with a bit for each hard register, and some macros to manipulate it.
3599 This type is just @code{int} if the machine has few enough hard registers;
3600 otherwise it is an array of @code{int} and some of the macros expand
3601 into loops.
3602
3603 @item
3604 Several passes use instruction attributes.  A definition of the
3605 attributes defined for a particular machine is in file
3606 @file{insn-attr.h}, which is generated from the machine description by
3607 the program @file{genattr}.  The file @file{insn-attrtab.c} contains
3608 subroutines to obtain the attribute values for insns.  It is generated
3609 from the machine description by the program @file{genattrtab}.@refill
3610 @end itemize
3611 @end ifset
3612
3613 @ifset INTERNALS
3614 @include c-tree.texi
3615 @include rtl.texi
3616 @include md.texi
3617 @include tm.texi
3618 @end ifset
3619
3620 @ifset INTERNALS
3621 @node Config
3622 @chapter The Configuration File
3623 @cindex configuration file
3624 @cindex @file{xm-@var{machine}.h}
3625
3626 The configuration file @file{xm-@var{machine}.h} contains macro
3627 definitions that describe the machine and system on which the compiler
3628 is running, unlike the definitions in @file{@var{machine}.h}, which
3629 describe the machine for which the compiler is producing output.  Most
3630 of the values in @file{xm-@var{machine}.h} are actually the same on all
3631 machines that GCC runs on, so large parts of all configuration files
3632 are identical.  But there are some macros that vary:
3633
3634 @table @code
3635 @findex USG
3636 @item USG
3637 Define this macro if the host system is System V.
3638
3639 @findex VMS
3640 @item VMS
3641 Define this macro if the host system is VMS.
3642
3643 @findex FATAL_EXIT_CODE
3644 @item FATAL_EXIT_CODE
3645 A C expression for the status code to be returned when the compiler
3646 exits after serious errors.  The default is the system-provided macro
3647 @samp{EXIT_FAILURE}, or @samp{1} if the system doesn't define that
3648 macro.  Define this macro only if these defaults are incorrect.
3649
3650 @findex SUCCESS_EXIT_CODE
3651 @item SUCCESS_EXIT_CODE
3652 A C expression for the status code to be returned when the compiler
3653 exits without serious errors.  (Warnings are not serious errors.)  The
3654 default is the system-provided macro @samp{EXIT_SUCCESS}, or @samp{0} if
3655 the system doesn't define that macro.  Define this macro only if these
3656 defaults are incorrect.
3657
3658 @findex HOST_WORDS_BIG_ENDIAN
3659 @item HOST_WORDS_BIG_ENDIAN
3660 Defined if the host machine stores words of multi-word values in
3661 big-endian order.  (GCC does not depend on the host byte ordering
3662 within a word.)
3663
3664 @findex HOST_FLOAT_WORDS_BIG_ENDIAN
3665 @item HOST_FLOAT_WORDS_BIG_ENDIAN
3666 Define this macro to be 1 if the host machine stores @code{DFmode},
3667 @code{XFmode} or @code{TFmode} floating point numbers in memory with the
3668 word containing the sign bit at the lowest address; otherwise, define it
3669 to be zero.
3670
3671 This macro need not be defined if the ordering is the same as for
3672 multi-word integers.
3673
3674 @findex HOST_FLOAT_FORMAT
3675 @item HOST_FLOAT_FORMAT
3676 A numeric code distinguishing the floating point format for the host
3677 machine.  See @code{TARGET_FLOAT_FORMAT} in @ref{Storage Layout} for the
3678 alternatives and default.
3679
3680 @findex HOST_BITS_PER_CHAR
3681 @item HOST_BITS_PER_CHAR
3682 A C expression for the number of bits in @code{char} on the host
3683 machine.
3684
3685 @findex HOST_BITS_PER_SHORT
3686 @item HOST_BITS_PER_SHORT
3687 A C expression for the number of bits in @code{short} on the host
3688 machine.
3689
3690 @findex HOST_BITS_PER_INT
3691 @item HOST_BITS_PER_INT
3692 A C expression for the number of bits in @code{int} on the host
3693 machine.
3694
3695 @findex HOST_BITS_PER_LONG
3696 @item HOST_BITS_PER_LONG
3697 A C expression for the number of bits in @code{long} on the host
3698 machine.
3699
3700 @findex ONLY_INT_FIELDS
3701 @item ONLY_INT_FIELDS
3702 Define this macro to indicate that the host compiler only supports
3703 @code{int} bit fields, rather than other integral types, including
3704 @code{enum}, as do most C compilers.
3705
3706 @findex OBSTACK_CHUNK_SIZE
3707 @item OBSTACK_CHUNK_SIZE
3708 A C expression for the size of ordinary obstack chunks.
3709 If you don't define this, a usually-reasonable default is used.
3710
3711 @findex OBSTACK_CHUNK_ALLOC
3712 @item OBSTACK_CHUNK_ALLOC
3713 The function used to allocate obstack chunks.
3714 If you don't define this, @code{xmalloc} is used.
3715
3716 @findex OBSTACK_CHUNK_FREE
3717 @item OBSTACK_CHUNK_FREE
3718 The function used to free obstack chunks.
3719 If you don't define this, @code{free} is used.
3720
3721 @findex USE_C_ALLOCA
3722 @item USE_C_ALLOCA
3723 Define this macro to indicate that the compiler is running with the
3724 @code{alloca} implemented in C.  This version of @code{alloca} can be
3725 found in the file @file{alloca.c}; to use it, you must also alter the
3726 @file{Makefile} variable @code{ALLOCA}.  (This is done automatically
3727 for the systems on which we know it is needed.)
3728
3729 If you do define this macro, you should probably do it as follows:
3730
3731 @example
3732 #ifndef __GNUC__
3733 #define USE_C_ALLOCA
3734 #else
3735 #define alloca __builtin_alloca
3736 #endif
3737 @end example
3738
3739 @noindent
3740 so that when the compiler is compiled with GCC it uses the more
3741 efficient built-in @code{alloca} function.
3742
3743 @item FUNCTION_CONVERSION_BUG
3744 @findex FUNCTION_CONVERSION_BUG
3745 Define this macro to indicate that the host compiler does not properly
3746 handle converting a function value to a pointer-to-function when it is
3747 used in an expression.
3748
3749 @findex MULTIBYTE_CHARS
3750 @item MULTIBYTE_CHARS
3751 Define this macro to enable support for multibyte characters in the
3752 input to GCC.  This requires that the host system support the ISO C
3753 library functions for converting multibyte characters to wide
3754 characters.
3755
3756 @findex POSIX
3757 @item POSIX
3758 Define this if your system is POSIX.1 compliant.
3759
3760 @findex PATH_SEPARATOR
3761 @item PATH_SEPARATOR
3762 Define this macro to be a C character constant representing the
3763 character used to separate components in paths.  The default value is
3764 the colon character
3765
3766 @findex DIR_SEPARATOR
3767 @item DIR_SEPARATOR
3768 If your system uses some character other than slash to separate
3769 directory names within a file specification, define this macro to be a C
3770 character constant specifying that character.  When GCC displays file
3771 names, the character you specify will be used.  GCC will test for
3772 both slash and the character you specify when parsing filenames.
3773
3774 @findex TARGET_OBJECT_SUFFIX
3775 @item TARGET_OBJECT_SUFFIX
3776 Define this macro to be a C string representing the suffix for object
3777 files on your target machine.  If you do not define this macro, GCC will
3778 use @samp{.o} as the suffix for object files.
3779
3780 @findex TARGET_EXECUTABLE_SUFFIX
3781 @item TARGET_EXECUTABLE_SUFFIX
3782 Define this macro to be a C string representing the suffix to be
3783 automatically added to executable files on your target machine.  If you
3784 do not define this macro, GCC will use the null string as the suffix for
3785 executable files.
3786
3787 @findex HOST_OBJECT_SUFFIX
3788 @item HOST_OBJECT_SUFFIX
3789 Define this macro to be a C string representing the suffix for object
3790 files on your host machine (@samp{xm-*.h}).  If you do not define this
3791 macro, GCC will use @samp{.o} as the suffix for object files.
3792
3793 @findex HOST_EXECUTABLE_SUFFIX
3794 @item HOST_EXECUTABLE_SUFFIX
3795 Define this macro to be a C string representing the suffix for
3796 executable files on your host machine (@samp{xm-*.h}).  If you do not
3797 define this macro, GCC will use the null string as the suffix for
3798 executable files.
3799
3800 @findex HOST_BIT_BUCKET
3801 @item HOST_BIT_BUCKET
3802 The name of a file or file-like object on the host system which acts as
3803 a ``bit bucket''.  If you do not define this macro, GCC will use
3804 @samp{/dev/null} as the bit bucket.  If the target does not support a
3805 bit bucket, this should be defined to the null string, or some other
3806 illegal filename.  If the bit bucket is not writable, GCC will use a
3807 temporary file instead.
3808
3809 @findex COLLECT_EXPORT_LIST
3810 @item COLLECT_EXPORT_LIST
3811 If defined, @code{collect2} will scan the individual object files
3812 specified on its command line and create an export list for the linker.
3813 Define this macro for systems like AIX, where the linker discards
3814 object files that are not referenced from @code{main} and uses export
3815 lists.
3816
3817 @findex COLLECT2_HOST_INITIALIZATION
3818 @item COLLECT2_HOST_INITIALIZATION
3819 If defined, a C statement (sans semicolon) that performs host-dependent
3820 initialization when @code{collect2} is being initialized.
3821
3822 @findex GCC_DRIVER_HOST_INITIALIZATION
3823 @item GCC_DRIVER_HOST_INITIALIZATION
3824 If defined, a C statement (sans semicolon) that performs host-dependent
3825 initialization when a compilation driver is being initialized.
3826
3827 @findex UPDATE_PATH_HOST_CANONICALIZE
3828 @item UPDATE_PATH_HOST_CANONICALIZE (@var{path}, @var{key})
3829 If defined, a C statement (sans semicolon) that performs host-dependent
3830 canonicalization when a path used in a compilation driver or preprocessor is
3831 canonicalized. @var{path} is the path to be canonicalized, and @var{key} is
3832 a translation prefix when its value isn't @code{NULL}. If the C statement
3833 does canonicalize @var{path}, the new path should be returned.
3834 @end table
3835
3836 @findex bzero
3837 @findex bcmp
3838 In addition, configuration files for system V define @code{bcopy},
3839 @code{bzero} and @code{bcmp} as aliases.  Some files define @code{alloca}
3840 as a macro when compiled with GCC, in order to take advantage of the
3841 benefit of GCC's built-in @code{alloca}.
3842
3843 @node Fragments
3844 @chapter Makefile Fragments
3845 @cindex makefile fragment
3846
3847 When you configure GCC using the @file{configure} script
3848 (@pxref{Installation}), it will construct the file @file{Makefile} from
3849 the template file @file{Makefile.in}.  When it does this, it will
3850 incorporate makefile fragment files from the @file{config} directory,
3851 named @file{t-@var{target}} and @file{x-@var{host}}.  If these files do
3852 not exist, it means nothing needs to be added for a given target or
3853 host.
3854
3855 @menu
3856 * Target Fragment:: Writing the @file{t-@var{target}} file.
3857 * Host Fragment::   Writing the @file{x-@var{host}} file.
3858 @end menu
3859
3860 @node Target Fragment
3861 @section The Target Makefile Fragment
3862 @cindex target makefile fragment
3863 @cindex @file{t-@var{target}}
3864
3865 The target makefile fragment, @file{t-@var{target}}, defines special
3866 target dependent variables and targets used in the @file{Makefile}:
3867
3868 @table @code
3869 @findex LIBGCC2_CFLAGS
3870 @item LIBGCC2_CFLAGS
3871 Compiler flags to use when compiling @file{libgcc2.c}.
3872
3873 @findex LIB2FUNCS_EXTRA
3874 @item LIB2FUNCS_EXTRA
3875 A list of source file names to be compiled or assembled and inserted
3876 into @file{libgcc.a}.
3877
3878 @findex Floating Point Emulation
3879 @item Floating Point Emulation
3880 To have GCC include software floating point libraries in @file{libgcc.a}
3881 define @code{FPBIT} and @code{DPBIT} along with a few rules as follows:
3882 @smallexample
3883 # We want fine grained libraries, so use the new code
3884 # to build the floating point emulation libraries.
3885 FPBIT = fp-bit.c
3886 DPBIT = dp-bit.c
3887
3888
3889 fp-bit.c: $(srcdir)/config/fp-bit.c
3890         echo '#define FLOAT' > fp-bit.c
3891         cat $(srcdir)/config/fp-bit.c >> fp-bit.c
3892
3893 dp-bit.c: $(srcdir)/config/fp-bit.c
3894         cat $(srcdir)/config/fp-bit.c > dp-bit.c
3895 @end smallexample
3896
3897 You may need to provide additional #defines at the beginning of @file{fp-bit.c}
3898 and @file{dp-bit.c} to control target endianness and other options.
3899
3900
3901 @findex CRTSTUFF_T_CFLAGS
3902 @item CRTSTUFF_T_CFLAGS
3903 Special flags used when compiling @file{crtstuff.c}.
3904 @xref{Initialization}.
3905
3906 @findex CRTSTUFF_T_CFLAGS_S
3907 @item CRTSTUFF_T_CFLAGS_S
3908 Special flags used when compiling @file{crtstuff.c} for shared
3909 linking.  Used if you use @file{crtbeginS.o} and @file{crtendS.o}
3910 in @code{EXTRA-PARTS}.
3911 @xref{Initialization}.
3912
3913 @findex MULTILIB_OPTIONS
3914 @item MULTILIB_OPTIONS
3915 For some targets, invoking GCC in different ways produces objects
3916 that can not be linked together.  For example, for some targets GCC
3917 produces both big and little endian code.  For these targets, you must
3918 arrange for multiple versions of @file{libgcc.a} to be compiled, one for
3919 each set of incompatible options.  When GCC invokes the linker, it
3920 arranges to link in the right version of @file{libgcc.a}, based on
3921 the command line options used.
3922
3923 The @code{MULTILIB_OPTIONS} macro lists the set of options for which
3924 special versions of @file{libgcc.a} must be built.  Write options that
3925 are mutually incompatible side by side, separated by a slash.  Write
3926 options that may be used together separated by a space.  The build
3927 procedure will build all combinations of compatible options.
3928
3929 For example, if you set @code{MULTILIB_OPTIONS} to @samp{m68000/m68020
3930 msoft-float}, @file{Makefile} will build special versions of
3931 @file{libgcc.a} using the following sets of options:  @option{-m68000},
3932 @option{-m68020}, @option{-msoft-float}, @samp{-m68000 -msoft-float}, and
3933 @samp{-m68020 -msoft-float}.
3934
3935 @findex MULTILIB_DIRNAMES
3936 @item MULTILIB_DIRNAMES
3937 If @code{MULTILIB_OPTIONS} is used, this variable specifies the
3938 directory names that should be used to hold the various libraries.
3939 Write one element in @code{MULTILIB_DIRNAMES} for each element in
3940 @code{MULTILIB_OPTIONS}.  If @code{MULTILIB_DIRNAMES} is not used, the
3941 default value will be @code{MULTILIB_OPTIONS}, with all slashes treated
3942 as spaces.
3943
3944 For example, if @code{MULTILIB_OPTIONS} is set to @samp{m68000/m68020
3945 msoft-float}, then the default value of @code{MULTILIB_DIRNAMES} is
3946 @samp{m68000 m68020 msoft-float}.  You may specify a different value if
3947 you desire a different set of directory names.
3948
3949 @findex MULTILIB_MATCHES
3950 @item MULTILIB_MATCHES
3951 Sometimes the same option may be written in two different ways.  If an
3952 option is listed in @code{MULTILIB_OPTIONS}, GCC needs to know about
3953 any synonyms.  In that case, set @code{MULTILIB_MATCHES} to a list of
3954 items of the form @samp{option=option} to describe all relevant
3955 synonyms.  For example, @samp{m68000=mc68000 m68020=mc68020}.
3956
3957 @findex MULTILIB_EXCEPTIONS
3958 @item MULTILIB_EXCEPTIONS
3959 Sometimes when there are multiple sets of @code{MULTILIB_OPTIONS} being
3960 specified, there are combinations that should not be built.  In that
3961 case, set @code{MULTILIB_EXCEPTIONS} to be all of the switch exceptions
3962 in shell case syntax that should not be built.
3963
3964 For example, in the PowerPC embedded ABI support, it is not desirable
3965 to build libraries compiled with the @option{-mcall-aix} option
3966 and either of the @option{-fleading-underscore} or @option{-mlittle} options
3967 at the same time.  Therefore @code{MULTILIB_EXCEPTIONS} is set to
3968 @code{*mcall-aix/*fleading-underscore* *mlittle/*mcall-aix*}.
3969
3970 @findex MULTILIB_EXTRA_OPTS
3971 @item MULTILIB_EXTRA_OPTS
3972 Sometimes it is desirable that when building multiple versions of
3973 @file{libgcc.a} certain options should always be passed on to the
3974 compiler.  In that case, set @code{MULTILIB_EXTRA_OPTS} to be the list
3975 of options to be used for all builds.
3976 @end table
3977
3978 @node Host Fragment
3979 @section The Host Makefile Fragment
3980 @cindex host makefile fragment
3981 @cindex @file{x-@var{host}}
3982
3983 The host makefile fragment, @file{x-@var{host}}, defines special host
3984 dependent variables and targets used in the @file{Makefile}:
3985
3986 @table @code
3987 @findex CC
3988 @item CC
3989 The compiler to use when building the first stage.
3990
3991 @findex INSTALL
3992 @item INSTALL
3993 The install program to use.
3994 @end table
3995 @end ifset
3996
3997 @node Funding
3998 @unnumbered Funding Free Software
3999
4000 If you want to have more free software a few years from now, it makes
4001 sense for you to help encourage people to contribute funds for its
4002 development.  The most effective approach known is to encourage
4003 commercial redistributors to donate.
4004
4005 Users of free software systems can boost the pace of development by
4006 encouraging for-a-fee distributors to donate part of their selling price
4007 to free software developers---the Free Software Foundation, and others.
4008
4009 The way to convince distributors to do this is to demand it and expect
4010 it from them.  So when you compare distributors, judge them partly by
4011 how much they give to free software development.  Show distributors
4012 they must compete to be the one who gives the most.
4013
4014 To make this approach work, you must insist on numbers that you can
4015 compare, such as, ``We will donate ten dollars to the Frobnitz project
4016 for each disk sold.''  Don't be satisfied with a vague promise, such as
4017 ``A portion of the profits are donated,'' since it doesn't give a basis
4018 for comparison.
4019
4020 Even a precise fraction ``of the profits from this disk'' is not very
4021 meaningful, since creative accounting and unrelated business decisions
4022 can greatly alter what fraction of the sales price counts as profit.
4023 If the price you pay is $50, ten percent of the profit is probably
4024 less than a dollar; it might be a few cents, or nothing at all.
4025
4026 Some redistributors do development work themselves.  This is useful too;
4027 but to keep everyone honest, you need to inquire how much they do, and
4028 what kind.  Some kinds of development make much more long-term
4029 difference than others.  For example, maintaining a separate version of
4030 a program contributes very little; maintaining the standard version of a
4031 program for the whole community contributes much.  Easy new ports
4032 contribute little, since someone else would surely do them; difficult
4033 ports such as adding a new CPU to the GNU Compiler Collection contribute more;
4034 major new features or packages contribute the most.
4035
4036 By establishing the idea that supporting further development is ``the
4037 proper thing to do'' when distributing free software for a fee, we can
4038 assure a steady flow of resources into making more free software.
4039
4040 @display
4041 Copyright (C) 1994 Free Software Foundation, Inc.
4042 Verbatim copying and redistribution of this section is permitted
4043 without royalty; alteration is not permitted.
4044 @end display
4045
4046 @node GNU/Linux
4047 @unnumbered Linux and the GNU Project
4048
4049 Many computer users run a modified version of the GNU system every
4050 day, without realizing it.  Through a peculiar turn of events, the
4051 version of GNU which is widely used today is more often known as
4052 ``Linux'', and many users are not aware of the extent of its
4053 connection with the GNU Project.
4054
4055 There really is a Linux; it is a kernel, and these people are using
4056 it.  But you can't use a kernel by itself; a kernel is useful only as
4057 part of a whole system.  The system in which Linux is typically used
4058 is a modified variant of the GNU system---in other words, a Linux-based
4059 GNU system.
4060
4061 Many users are not fully aware of the distinction between the kernel,
4062 which is Linux, and the whole system, which they also call ``Linux''.
4063 The ambiguous use of the name doesn't promote understanding.
4064
4065 Programmers generally know that Linux is a kernel.  But since they
4066 have generally heard the whole system called ``Linux'' as well, they
4067 often envisage a history which fits that name.  For example, many
4068 believe that once Linus Torvalds finished writing the kernel, his
4069 friends looked around for other free software, and for no particular
4070 reason most everything necessary to make a Unix-like system was
4071 already available.
4072
4073 What they found was no accident---it was the GNU system.  The available
4074 free software added up to a complete system because the GNU Project
4075 had been working since 1984 to make one.  The GNU Manifesto
4076 had set forth the goal of developing a free Unix-like system, called
4077 GNU.  By the time Linux was written, the system was almost finished.
4078
4079 Most free software projects have the goal of developing a particular
4080 program for a particular job.  For example, Linus Torvalds set out to
4081 write a Unix-like kernel (Linux); Donald Knuth set out to write a text
4082 formatter (TeX); Bob Scheifler set out to develop a window system (X
4083 Windows).  It's natural to measure the contribution of this kind of
4084 project by specific programs that came from the project.
4085
4086 If we tried to measure the GNU Project's contribution in this way,
4087 what would we conclude?  One CD-ROM vendor found that in their ``Linux
4088 distribution'', GNU software was the largest single contingent, around
4089 28% of the total source code, and this included some of the essential
4090 major components without which there could be no system.  Linux itself
4091 was about 3%.  So if you were going to pick a name for the system
4092 based on who wrote the programs in the system, the most appropriate
4093 single choice would be ``GNU''.
4094
4095 But we don't think that is the right way to consider the question.
4096 The GNU Project was not, is not, a project to develop specific
4097 software packages.  It was not a project to develop a C compiler,
4098 although we did.  It was not a project to develop a text editor,
4099 although we developed one.  The GNU Project's aim was to develop
4100 @emph{a complete free Unix-like system}.
4101
4102 Many people have made major contributions to the free software in the
4103 system, and they all deserve credit.  But the reason it is @emph{a
4104 system}---and not just a collection of useful programs---is because the
4105 GNU Project set out to make it one.  We wrote the programs that were
4106 needed to make a @emph{complete} free system.  We wrote essential but
4107 unexciting major components, such as the assembler and linker, because
4108 you can't have a system without them.  A complete system needs more
4109 than just programming tools, so we wrote other components as well,
4110 such as the Bourne Again SHell, the PostScript interpreter
4111 Ghostscript, and the GNU C library.
4112
4113 By the early 90s we had put together the whole system aside from the
4114 kernel (and we were also working on a kernel, the GNU Hurd, which runs
4115 on top of Mach).  Developing this kernel has been a lot harder than we
4116 expected, and we are still working on finishing it.
4117
4118 Fortunately, you don't have to wait for it, because Linux is working
4119 now.  When Linus Torvalds wrote Linux, he filled the last major gap.
4120 People could then put Linux together with the GNU system to make a
4121 complete free system: a Linux-based GNU system (or GNU/Linux system,
4122 for short).
4123
4124 Putting them together sounds simple, but it was not a trivial job.
4125 The GNU C library (called glibc for short) needed substantial changes.
4126 Integrating a complete system as a distribution that would work ``out
4127 of the box'' was a big job, too.  It required addressing the issue of
4128 how to install and boot the system---a problem we had not tackled,
4129 because we hadn't yet reached that point.  The people who developed
4130 the various system distributions made a substantial contribution.
4131
4132 The GNU Project supports GNU/Linux systems as well as @emph{the}
4133 GNU system---even with funds.  We funded the rewriting of the
4134 Linux-related extensions to the GNU C library, so that now they are
4135 well integrated, and the newest GNU/Linux systems use the current
4136 library release with no changes.  We also funded an early stage of the
4137 development of Debian GNU/Linux.
4138
4139 We use Linux-based GNU systems today for most of our work, and we hope
4140 you use them too.  But please don't confuse the public by using the
4141 name ``Linux'' ambiguously.  Linux is the kernel, one of the essential
4142 major components of the system.  The system as a whole is more or less
4143 the GNU system.
4144
4145 @node Copying
4146 @unnumbered GNU GENERAL PUBLIC LICENSE
4147 @center Version 2, June 1991
4148
4149 @display
4150 Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
4151 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
4152
4153 Everyone is permitted to copy and distribute verbatim copies
4154 of this license document, but changing it is not allowed.
4155 @end display
4156
4157 @unnumberedsec Preamble
4158
4159   The licenses for most software are designed to take away your
4160 freedom to share and change it.  By contrast, the GNU General Public
4161 License is intended to guarantee your freedom to share and change free
4162 software---to make sure the software is free for all its users.  This
4163 General Public License applies to most of the Free Software
4164 Foundation's software and to any other program whose authors commit to
4165 using it.  (Some other Free Software Foundation software is covered by
4166 the GNU Library General Public License instead.)  You can apply it to
4167 your programs, too.
4168
4169   When we speak of free software, we are referring to freedom, not
4170 price.  Our General Public Licenses are designed to make sure that you
4171 have the freedom to distribute copies of free software (and charge for
4172 this service if you wish), that you receive source code or can get it
4173 if you want it, that you can change the software or use pieces of it
4174 in new free programs; and that you know you can do these things.
4175
4176   To protect your rights, we need to make restrictions that forbid
4177 anyone to deny you these rights or to ask you to surrender the rights.
4178 These restrictions translate to certain responsibilities for you if you
4179 distribute copies of the software, or if you modify it.
4180
4181   For example, if you distribute copies of such a program, whether
4182 gratis or for a fee, you must give the recipients all the rights that
4183 you have.  You must make sure that they, too, receive or can get the
4184 source code.  And you must show them these terms so they know their
4185 rights.
4186
4187   We protect your rights with two steps: (1) copyright the software, and
4188 (2) offer you this license which gives you legal permission to copy,
4189 distribute and/or modify the software.
4190
4191   Also, for each author's protection and ours, we want to make certain
4192 that everyone understands that there is no warranty for this free
4193 software.  If the software is modified by someone else and passed on, we
4194 want its recipients to know that what they have is not the original, so
4195 that any problems introduced by others will not reflect on the original
4196 authors' reputations.
4197
4198   Finally, any free program is threatened constantly by software
4199 patents.  We wish to avoid the danger that redistributors of a free
4200 program will individually obtain patent licenses, in effect making the
4201 program proprietary.  To prevent this, we have made it clear that any
4202 patent must be licensed for everyone's free use or not licensed at all.
4203
4204   The precise terms and conditions for copying, distribution and
4205 modification follow.
4206
4207 @iftex
4208 @unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
4209 @end iftex
4210 @ifnottex
4211 @center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
4212 @end ifnottex
4213
4214 @enumerate 0
4215 @item
4216 This License applies to any program or other work which contains
4217 a notice placed by the copyright holder saying it may be distributed
4218 under the terms of this General Public License.  The ``Program'', below,
4219 refers to any such program or work, and a ``work based on the Program''
4220 means either the Program or any derivative work under copyright law:
4221 that is to say, a work containing the Program or a portion of it,
4222 either verbatim or with modifications and/or translated into another
4223 language.  (Hereinafter, translation is included without limitation in
4224 the term ``modification''.)  Each licensee is addressed as ``you''.
4225
4226 Activities other than copying, distribution and modification are not
4227 covered by this License; they are outside its scope.  The act of
4228 running the Program is not restricted, and the output from the Program
4229 is covered only if its contents constitute a work based on the
4230 Program (independent of having been made by running the Program).
4231 Whether that is true depends on what the Program does.
4232
4233 @item
4234 You may copy and distribute verbatim copies of the Program's
4235 source code as you receive it, in any medium, provided that you
4236 conspicuously and appropriately publish on each copy an appropriate
4237 copyright notice and disclaimer of warranty; keep intact all the
4238 notices that refer to this License and to the absence of any warranty;
4239 and give any other recipients of the Program a copy of this License
4240 along with the Program.
4241
4242 You may charge a fee for the physical act of transferring a copy, and
4243 you may at your option offer warranty protection in exchange for a fee.
4244
4245 @item
4246 You may modify your copy or copies of the Program or any portion
4247 of it, thus forming a work based on the Program, and copy and
4248 distribute such modifications or work under the terms of Section 1
4249 above, provided that you also meet all of these conditions:
4250
4251 @enumerate a
4252 @item
4253 You must cause the modified files to carry prominent notices
4254 stating that you changed the files and the date of any change.
4255
4256 @item
4257 You must cause any work that you distribute or publish, that in
4258 whole or in part contains or is derived from the Program or any
4259 part thereof, to be licensed as a whole at no charge to all third
4260 parties under the terms of this License.
4261
4262 @item
4263 If the modified program normally reads commands interactively
4264 when run, you must cause it, when started running for such
4265 interactive use in the most ordinary way, to print or display an
4266 announcement including an appropriate copyright notice and a
4267 notice that there is no warranty (or else, saying that you provide
4268 a warranty) and that users may redistribute the program under
4269 these conditions, and telling the user how to view a copy of this
4270 License.  (Exception: if the Program itself is interactive but
4271 does not normally print such an announcement, your work based on
4272 the Program is not required to print an announcement.)
4273 @end enumerate
4274
4275 These requirements apply to the modified work as a whole.  If
4276 identifiable sections of that work are not derived from the Program,
4277 and can be reasonably considered independent and separate works in
4278 themselves, then this License, and its terms, do not apply to those
4279 sections when you distribute them as separate works.  But when you
4280 distribute the same sections as part of a whole which is a work based
4281 on the Program, the distribution of the whole must be on the terms of
4282 this License, whose permissions for other licensees extend to the
4283 entire whole, and thus to each and every part regardless of who wrote it.
4284
4285 Thus, it is not the intent of this section to claim rights or contest
4286 your rights to work written entirely by you; rather, the intent is to
4287 exercise the right to control the distribution of derivative or
4288 collective works based on the Program.
4289
4290 In addition, mere aggregation of another work not based on the Program
4291 with the Program (or with a work based on the Program) on a volume of
4292 a storage or distribution medium does not bring the other work under
4293 the scope of this License.
4294
4295 @item
4296 You may copy and distribute the Program (or a work based on it,
4297 under Section 2) in object code or executable form under the terms of
4298 Sections 1 and 2 above provided that you also do one of the following:
4299
4300 @enumerate a
4301 @item
4302 Accompany it with the complete corresponding machine-readable
4303 source code, which must be distributed under the terms of Sections
4304 1 and 2 above on a medium customarily used for software interchange; or,
4305
4306 @item
4307 Accompany it with a written offer, valid for at least three
4308 years, to give any third party, for a charge no more than your
4309 cost of physically performing source distribution, a complete
4310 machine-readable copy of the corresponding source code, to be
4311 distributed under the terms of Sections 1 and 2 above on a medium
4312 customarily used for software interchange; or,
4313
4314 @item
4315 Accompany it with the information you received as to the offer
4316 to distribute corresponding source code.  (This alternative is
4317 allowed only for noncommercial distribution and only if you
4318 received the program in object code or executable form with such
4319 an offer, in accord with Subsection b above.)
4320 @end enumerate
4321
4322 The source code for a work means the preferred form of the work for
4323 making modifications to it.  For an executable work, complete source
4324 code means all the source code for all modules it contains, plus any
4325 associated interface definition files, plus the scripts used to
4326 control compilation and installation of the executable.  However, as a
4327 special exception, the source code distributed need not include
4328 anything that is normally distributed (in either source or binary
4329 form) with the major components (compiler, kernel, and so on) of the
4330 operating system on which the executable runs, unless that component
4331 itself accompanies the executable.
4332
4333 If distribution of executable or object code is made by offering
4334 access to copy from a designated place, then offering equivalent
4335 access to copy the source code from the same place counts as
4336 distribution of the source code, even though third parties are not
4337 compelled to copy the source along with the object code.
4338
4339 @item
4340 You may not copy, modify, sublicense, or distribute the Program
4341 except as expressly provided under this License.  Any attempt
4342 otherwise to copy, modify, sublicense or distribute the Program is
4343 void, and will automatically terminate your rights under this License.
4344 However, parties who have received copies, or rights, from you under
4345 this License will not have their licenses terminated so long as such
4346 parties remain in full compliance.
4347
4348 @item
4349 You are not required to accept this License, since you have not
4350 signed it.  However, nothing else grants you permission to modify or
4351 distribute the Program or its derivative works.  These actions are
4352 prohibited by law if you do not accept this License.  Therefore, by
4353 modifying or distributing the Program (or any work based on the
4354 Program), you indicate your acceptance of this License to do so, and
4355 all its terms and conditions for copying, distributing or modifying
4356 the Program or works based on it.
4357
4358 @item
4359 Each time you redistribute the Program (or any work based on the
4360 Program), the recipient automatically receives a license from the
4361 original licensor to copy, distribute or modify the Program subject to
4362 these terms and conditions.  You may not impose any further
4363 restrictions on the recipients' exercise of the rights granted herein.
4364 You are not responsible for enforcing compliance by third parties to
4365 this License.
4366
4367 @item
4368 If, as a consequence of a court judgment or allegation of patent
4369 infringement or for any other reason (not limited to patent issues),
4370 conditions are imposed on you (whether by court order, agreement or
4371 otherwise) that contradict the conditions of this License, they do not
4372 excuse you from the conditions of this License.  If you cannot
4373 distribute so as to satisfy simultaneously your obligations under this
4374 License and any other pertinent obligations, then as a consequence you
4375 may not distribute the Program at all.  For example, if a patent
4376 license would not permit royalty-free redistribution of the Program by
4377 all those who receive copies directly or indirectly through you, then
4378 the only way you could satisfy both it and this License would be to
4379 refrain entirely from distribution of the Program.
4380
4381 If any portion of this section is held invalid or unenforceable under
4382 any particular circumstance, the balance of the section is intended to
4383 apply and the section as a whole is intended to apply in other
4384 circumstances.
4385
4386 It is not the purpose of this section to induce you to infringe any
4387 patents or other property right claims or to contest validity of any
4388 such claims; this section has the sole purpose of protecting the
4389 integrity of the free software distribution system, which is
4390 implemented by public license practices.  Many people have made
4391 generous contributions to the wide range of software distributed
4392 through that system in reliance on consistent application of that
4393 system; it is up to the author/donor to decide if he or she is willing
4394 to distribute software through any other system and a licensee cannot
4395 impose that choice.
4396
4397 This section is intended to make thoroughly clear what is believed to
4398 be a consequence of the rest of this License.
4399
4400 @item
4401 If the distribution and/or use of the Program is restricted in
4402 certain countries either by patents or by copyrighted interfaces, the
4403 original copyright holder who places the Program under this License
4404 may add an explicit geographical distribution limitation excluding
4405 those countries, so that distribution is permitted only in or among
4406 countries not thus excluded.  In such case, this License incorporates
4407 the limitation as if written in the body of this License.
4408
4409 @item
4410 The Free Software Foundation may publish revised and/or new versions
4411 of the General Public License from time to time.  Such new versions will
4412 be similar in spirit to the present version, but may differ in detail to
4413 address new problems or concerns.
4414
4415 Each version is given a distinguishing version number.  If the Program
4416 specifies a version number of this License which applies to it and ``any
4417 later version'', you have the option of following the terms and conditions
4418 either of that version or of any later version published by the Free
4419 Software Foundation.  If the Program does not specify a version number of
4420 this License, you may choose any version ever published by the Free Software
4421 Foundation.
4422
4423 @item
4424 If you wish to incorporate parts of the Program into other free
4425 programs whose distribution conditions are different, write to the author
4426 to ask for permission.  For software which is copyrighted by the Free
4427 Software Foundation, write to the Free Software Foundation; we sometimes
4428 make exceptions for this.  Our decision will be guided by the two goals
4429 of preserving the free status of all derivatives of our free software and
4430 of promoting the sharing and reuse of software generally.
4431
4432 @iftex
4433 @heading NO WARRANTY
4434 @end iftex
4435 @ifnottex
4436 @center NO WARRANTY
4437 @end ifnottex
4438
4439 @item
4440 BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
4441 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
4442 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
4443 PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
4444 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
4445 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
4446 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
4447 PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
4448 REPAIR OR CORRECTION.
4449
4450 @item
4451 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
4452 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
4453 REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
4454 INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
4455 OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
4456 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
4457 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
4458 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
4459 POSSIBILITY OF SUCH DAMAGES.
4460 @end enumerate
4461
4462 @iftex
4463 @heading END OF TERMS AND CONDITIONS
4464 @end iftex
4465 @ifnottex
4466 @center END OF TERMS AND CONDITIONS
4467 @end ifnottex
4468
4469 @page
4470 @unnumberedsec How to Apply These Terms to Your New Programs
4471
4472   If you develop a new program, and you want it to be of the greatest
4473 possible use to the public, the best way to achieve this is to make it
4474 free software which everyone can redistribute and change under these terms.
4475
4476   To do so, attach the following notices to the program.  It is safest
4477 to attach them to the start of each source file to most effectively
4478 convey the exclusion of warranty; and each file should have at least
4479 the ``copyright'' line and a pointer to where the full notice is found.
4480
4481 @smallexample
4482 @var{one line to give the program's name and a brief idea of what it does.}
4483 Copyright (C) @var{yyyy}  @var{name of author}
4484
4485 This program is free software; you can redistribute it and/or modify
4486 it under the terms of the GNU General Public License as published by
4487 the Free Software Foundation; either version 2 of the License, or
4488 (at your option) any later version.
4489
4490 This program is distributed in the hope that it will be useful,
4491 but WITHOUT ANY WARRANTY; without even the implied warranty of
4492 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4493 GNU General Public License for more details.
4494
4495 You should have received a copy of the GNU General Public License
4496 along with this program; if not, write to the Free Software
4497 Foundation, Inc., 59 Temple Place - Suite 330,
4498 Boston, MA 02111-1307, USA.
4499 @end smallexample
4500
4501 Also add information on how to contact you by electronic and paper mail.
4502
4503 If the program is interactive, make it output a short notice like this
4504 when it starts in an interactive mode:
4505
4506 @smallexample
4507 Gnomovision version 69, Copyright (C) @var{yyyy} @var{name of author}
4508 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
4509 type `show w'.
4510 This is free software, and you are welcome to redistribute it
4511 under certain conditions; type `show c' for details.
4512 @end smallexample
4513
4514 The hypothetical commands @samp{show w} and @samp{show c} should show
4515 the appropriate parts of the General Public License.  Of course, the
4516 commands you use may be called something other than @samp{show w} and
4517 @samp{show c}; they could even be mouse-clicks or menu items---whatever
4518 suits your program.
4519
4520 You should also get your employer (if you work as a programmer) or your
4521 school, if any, to sign a ``copyright disclaimer'' for the program, if
4522 necessary.  Here is a sample; alter the names:
4523
4524 @smallexample
4525 Yoyodyne, Inc., hereby disclaims all copyright interest in the program
4526 `Gnomovision' (which makes passes at compilers) written by James Hacker.
4527
4528 @var{signature of Ty Coon}, 1 April 1989
4529 Ty Coon, President of Vice
4530 @end smallexample
4531
4532 This General Public License does not permit incorporating your program into
4533 proprietary programs.  If your program is a subroutine library, you may
4534 consider it more useful to permit linking proprietary applications with the
4535 library.  If this is what you want to do, use the GNU Library General
4536 Public License instead of this License.
4537
4538 @c ---------------------------------------------------------------------
4539 @c GFDL
4540 @c ---------------------------------------------------------------------
4541
4542 @include fdl.texi
4543
4544 @node Contributors
4545 @unnumbered Contributors to GCC
4546 @cindex contributors
4547 @include contrib.texi
4548
4549 @c ---------------------------------------------------------------------
4550 @c Indexes
4551 @c ---------------------------------------------------------------------
4552
4553 @node Option Index
4554 @unnumbered Option Index
4555
4556 GCC's command line options are indexed here without any initial @samp{-}
4557 or @samp{--}.  Where an option has both positive and negative forms
4558 (such as @option{-f@var{option}} and @option{-fno-@var{option}}),
4559 relevant entries in the manual are indexed under the most appropriate
4560 form; it may sometimes be useful to look up both forms.
4561
4562 @printindex op
4563
4564 @node Index
4565 @unnumbered Index
4566
4567 @printindex cp
4568
4569 @c ---------------------------------------------------------------------
4570 @c Epilogue
4571 @c ---------------------------------------------------------------------
4572
4573 @bye