@c %**start of header
@setfilename g77.info
-@set last-update 1999-04-02
-@set copyrights-g77 1995-1999
+@set last-update 2000-12-21
+@set copyrights-g77 1995,1996,1997,1998,1999,2000
@include root.texi
@ifset INTERNALS
* Adding Options:: Guidance on teaching @code{g77} about new options.
* Projects:: Projects for @code{g77} internals hackers.
+* Front End:: Design and implementation of the @code{g77} front end.
@end ifset
* M: Diagnostics. Diagnostics produced by @code{g77}.
@smallexample
@var{one line to give the program's name and a brief idea of what it does.}
-Copyright (C) 19@var{yy} @var{name of author}
+Copyright (C) @var{year} @var{name of author}
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
when it starts in an interactive mode:
@smallexample
-Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author}
+Gnomovision version 69, Copyright (C) @var{year} @var{name of author}
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
type `show w'.
This is free software, and you are welcome to redistribute it
experimental, options added by @code{g77} to the @code{gcc}
compiler and its back end.
-(These, in turn, have made their way into the @code{egcs}
+(These, in turn, had made their way into the @code{egcs}
version of the compiler, and do not exist in @code{gcc}
version 2.8 or versions of @code{g77} based on that version
of @code{gcc}.)
network connections, and so on, which are invaluable to volunteers.
(Similarly, hiring Cygnus Support can help a project like GNU
Fortran---Cygnus has been a long-time donor of equipment usage to the author
-of GNU Fortran, and this too has been invaluable---@xref{Contributors}.)
+of GNU Fortran, and this too has been invaluable---see @ref{Contributors}.)
Currently, the only way to directly fund the author of GNU Fortran
in his work on that project is to hire him for the work you want
@cindex GNU Fortran Front End (FFE)
@cindex FFE
@cindex @code{g77}, front end
-@cindex front end, g77
+@cindex front end, @code{g77}
The other chunk of @code{f771} is the
majority of what is unique about GNU Fortran---the code that knows how
to interpret Fortran programs to determine what they are intending to
@item Shorthand Options
@xref{Shorthand Options}.
@smallexample
--ff66 -fno-f66 -ff77 -fno-f77 -fugly -fno-ugly
+-ff66 -fno-f66 -ff77 -fno-f77 -fno-ugly
@end smallexample
@item Fortran Language Options
-malign-double
-ffloat-store -fforce-mem -fforce-addr -fno-inline
-ffast-math -fstrength-reduce -frerun-cse-after-loop
+-funsafe-math-optimizations -fno-trapping-math
-fexpensive-optimizations -fdelayed-branch
-fschedule-insns -fschedule-insn2 -fcaller-saves
-funroll-loops -funroll-all-loops
-fpcc-struct-return -freg-struct-return
-fshort-double -fno-common -fpack-struct
-fzeros -fno-second-underscore
--fdebug-kludge -fno-emulate-complex
+-fdebug-kludge -femulate-complex
-falias-check -fargument-alias
-fargument-noalias -fno-argument-noalias-global
--fno-globals
+-fno-globals -fflatten-arrays
+-fbounds-check -ffortran-bounds-check
@end smallexample
@end table
Such source code cannot contain any preprocessor directives, such
as @code{#include}, @code{#define}, @code{#if}, and so on.
-You can force @samp{.f} files to be preprocessed by @samp{cpp} by using
+You can force @samp{.f} files to be preprocessed by @code{cpp} by using
@samp{-x f77-cpp-input}.
@xref{LEX}.
@cindex options, -fversion
@cindex printing version information
@cindex version information, printing
+@cindex consistency checks
+@cindex internal consistency checks
+@cindex checks, of internal consistency
@item -fversion
Ensure that the @code{g77}-specific version of the compiler phase is reported,
-if run.
-(This is supplied automatically when @samp{-v} or @samp{--verbose}
+if run,
+and, starting in @code{egcs} version 1.1,
+that internal consistency checks in the @file{f771} program are run.
+
+This option is supplied automatically when @samp{-v} or @samp{--verbose}
is specified as a command-line option for @code{g77} or @code{gcc}
-and when the resulting commands compile Fortran source files.)
+and when the resulting commands compile Fortran source files.
@cindex -fset-g77-defaults option
@cindex options, -fset-g77-defaults
@item -fset-g77-defaults
@emph{Version info:}
-This option is obsolete in @code{egcs}
-as of version 1.1.
-
+This option was obsolete as of @code{egcs}
+version 1.1.
+The effect is instead achieved
+by the @code{lang_init_options} routine
+in @file{gcc/gcc/f/com.c}.
+
+@cindex consistency checks
+@cindex internal consistency checks
+@cindex checks, of internal consistency
Set up whatever @code{gcc} options are to apply to Fortran
compilations, and avoid running internal consistency checks
that might take some time.
@item -fugly
@cindex ugly features
@cindex features, ugly
+@emph{Note:} This option is no longer supported.
+The information, below, is provided to aid
+in the conversion of old scripts.
+
Specify that certain ``ugly'' constructs are to be quietly accepted.
Same as:
in old code.
@xref{Distensions}, for more information.
-@emph{Note:} The @samp{-fugly} option is likely to
-be removed in a future version.
-Implicitly enabling all the @samp{-fugly-*} options
-is unlikely to be feasible, or sensible, in the future,
-so users should learn to specify only those
-@samp{-fugly-*} options they really need for a
-particular source file.
-
@cindex -fno-ugly option
@cindex options, -fno-ugly
@item -fno-ugly
@cindex common blocks
@cindex equivalence areas
@cindex missing debug features
-Support for this option in Fortran programs is incomplete.
+Support for this option in Fortran programs was incomplete up till
+version 0.5.26 of @code{g77}.
In particular, names of variables and arrays in common blocks
-or that are storage-associated via @code{EQUIVALENCE} are
+or that are storage-associated via @code{EQUIVALENCE} were
unavailable to the debugger.
However, version 0.5.19 of @code{g77} does provide this information
in a rudimentary way, as controlled by the
@samp{-fdebug-kludge} option.
+Because version 0.5.26 of @code{g77} enables full debug information
+of COMMON BLOCK and EQUIVALENCE items, this option has been disabled.
+
@xref{Code Gen Options,,Options for Code Generation Conventions},
for more information.
@end table
this option does not apply, generally speaking, to Fortran
code compiled by @code{g77}.
-@emph{Also note:} @samp{-malign-double} applies only to
-statically-allocated data.
-Double-precision data on the stack can still
-cause problems due to misalignment.
-@xref{Aligned Data}.
+@xref{Aligned Data}, for more information on alignment issues.
@emph{Also also note:} The negative form of @samp{-malign-double}
is @samp{-mno-align-double}, not @samp{-benign-double}.
This option is effective when the floating-point unit is set to work in
IEEE 854 `extended precision'---as it typically is on x86 and m68k GNU
-systems---rather than IEEE 754 double precision. @code{-ffloat-store}
+systems---rather than IEEE 754 double precision. @samp{-ffloat-store}
tries to remove the extra precision by spilling data from floating-point
registers into memory and this typically involves a big performance
hit. However, it doesn't affect intermediate results, so that it is
@cindex conformance, IEEE 754
Might allow some programs designed to not be too dependent
on IEEE behavior for floating-point to run faster, or die trying.
+Sets @samp{-funsafe-math-optimizations}, and
+@samp{-fno-trapping-math}.
+
+@cindex -funsafe-math-optimizations option
+@cindex options, -funsafe-math-optimizations
+@item -funsafe-math-optimizations
+Allow optimizations that may be give incorrect results
+for certain IEEE inputs.
+
+@cindex -fno-trapping-math option
+@cindex options, -fno-trapping-math
+@item -fno-trapping-math
+Allow the compiler to assume that floating-point arithmetic
+will not generate traps on any inputs. This is useful, for
+example, when running a program using IEEE "non-stop"
+floating-point arithmetic.
@cindex -fstrength-reduce option
@cindex options, -fstrength-reduce
@c DL: Check my understanding of -funroll-all-loops v. -funroll-loops is correct.
Probably improves performance on code using @code{DO WHILE} loops by
unrolling them in addition to iterative @code{DO} loops. In the absence
-of @code{DO WHILE}, this option is equivalent to @code{-funroll-loops}
+of @code{DO WHILE}, this option is equivalent to @samp{-funroll-loops}
but possibly slower.
@item -fno-move-all-movables
information is suggested.
Use @samp{set language c} and @samp{set language fortran} to accomplish this.
+As of version 0.5.26 of @code{g77} this option has been disabled, as the
+compiler is now able to emit correct and complete debug information
+for COMMON BLOCK and EQUIVALENCE items.
+
For example:
@smallexample
(and its negative form).
Current plans call for this to happen when published versions of @code{g77}
and @code{gdb} exist that provide proper access to debugging information on
-@code{COMMON} and @code{EQUIVALENCE} members.
-
-@cindex -fno-emulate-complex option
-@cindex options, -fno-emulate-complex
-@item -fno-emulate-complex
-Implement @code{COMPLEX} arithmetic using the facilities in
+@code{COMMON} and @code{EQUIVALENCE} members. This is believed to have
+happened as of version 0.5.26 of @code{g77}, so that this option has been
+disabled starting with this release.
+
+@cindex -femulate-complex option
+@cindex options, -femulate-complex
+@item -femulate-complex
+Implement @code{COMPLEX} arithmetic via emulation,
+instead of using the facilities of
the @code{gcc} back end that provide direct support of
-@code{complex} arithmetic, instead of emulating the arithmetic.
+@code{complex} arithmetic.
-@code{gcc} has some known problems in its back-end support
+(@code{gcc} had some bugs in its back-end support
for @code{complex} arithmetic, due primarily to the support not being
-completed as of version 2.7.2.2.
-Other front ends for the @code{gcc} back end avoid this problem
-by emulating @code{complex} arithmetic at a higher level, so the
-back end sees arithmetic on the real and imaginary components.
-To make @code{g77} more portable to systems where @code{complex}
-support in the @code{gcc} back end is particularly troublesome,
-@code{g77} now defaults to performing the same kinds of emulations
-done by these other front ends.
-
-Use @samp{-fno-emulate-complex} to try the @code{complex} support
-in the @code{gcc} back end, in case it works and produces faster
-programs.
-So far, all the known bugs seem to involve compile-time crashes,
-rather than the generation of incorrect code.
+completed as of version 2.8.1 and @code{egcs} 1.1.2.)
+
+Use @samp{-femulate-complex} if you suspect code-generation bugs,
+or experience compiler crashes,
+that might result from @code{g77} using the @code{COMPLEX} support
+in the @code{gcc} back end.
+If using that option fixes the bugs or crashes you are seeing,
+that indicates a likely @code{g77} bugs
+(though, all compiler crashes are considered bugs),
+so, please report it.
+(Note that the known bugs, now believed fixed, produced compiler crashes
+rather than causing the generation of incorrect code.)
Use of this option should not affect how Fortran code compiled
by @code{g77} works in terms of its interfaces to other code,
e.g. that compiled by @code{f2c}.
-@emph{Caution:} Future versions of @code{g77} are likely to change
-the default for this option to
-@samp{-fno-emulate-complex}, and perhaps someday ignore both forms
+@emph{Caution:} Future versions of @code{g77} might ignore both forms
of this option.
-Also, it is possible that use of the @samp{-fno-emulate-complex} option
-could result in incorrect code being silently produced by @code{g77}.
-But, this is generally true of compilers anyway, so, as usual, test
-the programs you compile before assuming they are working.
-
@cindex -falias-check option
@cindex options, -falias-check
@cindex -fargument-alias option
that are currently believed to not
likely to result in the compiler later crashing
or producing incorrect code.
+
+@cindex -fflatten-arrays option
+@item -fflatten-arrays
+@cindex array performance
+@cindex arrays, flattening
+Use back end's C-like constructs
+(pointer plus offset)
+instead of its @code{ARRAY_REF} construct
+to handle all array references.
+
+@emph{Note:} This option is not supported.
+It is intended for use only by @code{g77} developers,
+to evaluate code-generation issues.
+It might be removed at any time.
+
+@cindex -fbounds-check option
+@cindex -ffortran-bounds-check option
+@item -fbounds-check
+@itemx -ffortran-bounds-check
+@cindex bounds checking
+@cindex range checking
+@cindex array bounds checking
+@cindex subscript checking
+@cindex substring checking
+@cindex checking subscripts
+@cindex checking substrings
+Enable generation of run-time checks for array subscripts
+and substring start and end points
+against the (locally) declared minimum and maximum values.
+
+The current implementation uses the @code{libf2c}
+library routine @code{s_rnge} to print the diagnostic.
+
+However, whereas @code{f2c} generates a single check per
+reference for a multi-dimensional array, of the computed
+offset against the valid offset range (0 through the size of the array),
+@code{g77} generates a single check per @emph{subscript} expression.
+This catches some cases of potential bugs that @code{f2c} does not,
+such as references to below the beginning of an assumed-size array.
+
+@code{g77} also generates checks for @code{CHARACTER} substring references,
+something @code{f2c} currently does not do.
+
+Use the new @samp{-ffortran-bounds-check} option
+to specify bounds-checking for only the Fortran code you are compiling,
+not necessarily for code written in other languages.
+
+@emph{Note:} To provide more detailed information on the offending subscript,
+@code{g77} provides the @code{libg2c} run-time library routine @code{s_rnge}
+with somewhat differently-formatted information.
+Here's a sample diagnostic:
+
+@smallexample
+Subscript out of range on file line 4, procedure rnge.f/bf.
+Attempt to access the -6-th element of variable b[subscript-2-of-2].
+Aborted
+@end smallexample
+
+The above message indicates that the offending source line is
+line 4 of the file @file{rnge.f},
+within the program unit (or statement function) named @samp{bf}.
+The offended array is named @samp{b}.
+The offended array dimension is the second for a two-dimensional array,
+and the offending, computed subscript expression was @samp{-6}.
+
+For a @code{CHARACTER} substring reference, the second line has
+this appearance:
+
+@smallexample
+Attempt to access the 11-th element of variable a[start-substring].
+@end smallexample
+
+This indicates that the offended @code{CHARACTER} variable or array
+is named @samp{a},
+the offended substring position is the starting (leftmost) position,
+and the offending substring expression is @samp{11}.
+
+(Though the verbage of @code{s_rnge} is not ideal
+for the purpose of the @code{g77} compiler,
+the above information should provide adequate diagnostic abilities
+to it users.)
@end table
@xref{Code Gen Options,,Options for Code Generation Conventions,
@item
A metasyntactic variable---that is, a name used in this document
to serve as a placeholder for whatever text is used by the
-user or programmer--appears as shown in the following example:
+user or programmer---appears as shown in the following example:
``The @code{INTEGER @var{ivar}} statement specifies that
@var{ivar} is a variable or array of type @code{INTEGER}.''
A newline in the file is the character that represents the end of
a line of text to the underlying system.
For example, on ASCII-based systems, a newline is the @key{NL}
-character, which has ASCII value 12 (decimal).
+character, which has ASCII value 10 (decimal).
@item
Each newline in the file serves to end the line of text that precedes
@cindex #
@cindex preprocessor
-@code{cpp} output-style @code{#} directives @xref{C Preprocessor
-Output,,, cpp, The C Preprocessor}, are recognized by the compiler even
+@code{cpp} output-style @code{#} directives
+(@pxref{C Preprocessor Output,,, cpp, The C Preprocessor})
+are recognized by the compiler even
when the preprocessor isn't run on the input (as it is when compiling
@samp{.F} files). (Note the distinction between these @code{cpp}
@code{#} @emph{output} directives and @code{#line} @emph{input}
and certainly existing Fortran programs, disagree about the
meaning of such invocations.
-The first version of @samp{JCB002} didn't accommodate some compilers'
+The first version of @code{JCB002} didn't accommodate some compilers'
treatment of @samp{INT(I1-I2)} where @samp{I1} and @samp{I2} are
@code{INTEGER*2}.
In such a case, these compilers apparently convert both
of programs compiled by these various compilers show that they
all implement either @samp{Interp 1} or @samp{Interp 2} above.
-Specifically, it is believed that the new version of @samp{JCB002}
+Specifically, it is believed that the new version of @code{JCB002}
above will confirm that:
@itemize @bullet
For convenience this section collects a list (probably incomplete) of
the Fortran 90 features supported by the GNU Fortran language, even if
they are documented elsewhere.
-@c makeinfo 1.68 objects to the nested parens
-@ifnotinfo
-@xref{Characters Lines Sequence,,{Characters, Lines, and Execution Sequence}},
-@end ifnotinfo
-@ifinfo
-@xref{Characters Lines Sequence},
-@end ifinfo
+@xref{Characters Lines Sequence,,@asis{Characters, Lines, and Execution Sequence}},
for information on additional fixed source form lexical issues.
@cindex @samp{-ffree-form}
Further, the free source form is supported through the
permitted. Character constants may be enclosed in double quotes
(@code{"}) as well as single quotes. @xref{Character Type}.
@item Construct names
-(Symbolic tags on blocks.) @xref{Construct Names }.
+(Symbolic tags on blocks.) @xref{Construct Names}.
@item @code{CYCLE} and @code{EXIT}
@xref{CYCLE and EXIT,,The @code{CYCLE} and @code{EXIT} Statements}.
@item @code{DOUBLE COMPLEX}
-@xref{DOUBLE COMPLEX,,@code{DOUBLE COMPLEX} Statement
-}.
+@xref{DOUBLE COMPLEX,,@code{DOUBLE COMPLEX} Statement}.
@item @code{DO WHILE}
@xref{DO WHILE}.
@item @code{END} decoration
@code{>=} may be used instead of @code{.LT.}, @code{.LE.}, @code{.EQ.},
@code{.NE.}, @code{.GT.} and @code{.GE.} respectively.
@item @code{SELECT CASE}
-Not fully implemented. @xref{SELECT CASE on CHARACTER Type,,
-@code{SELECT CASE} on @code{CHARACTER} Type}.
+Not fully implemented.
+@xref{SELECT CASE on CHARACTER Type,, @code{SELECT CASE} on @code{CHARACTER} Type}.
@item Specification statements
A limited subset of the Fortran 90 syntax and semantics for variable
declarations is supported, including @code{KIND}. @xref{Kind Notation}.
Note 2: Rules for InitialCaps names are:
-@itemize --
+@itemize @minus
@item
Must be a single uppercase letter, @strong{or}
@item
not.
Note that most, but not all, built-in names meet these
requirements---the exceptions are some of the two-letter format
-specifiers, such as @samp{BN} and @samp{BZ}.
+specifiers, such as @code{BN} and @code{BZ}.
Here are the names of the corresponding command-line options:
@code{g77} treats double-quote (@samp{"})
as beginning an octal constant of @code{INTEGER(KIND=1)} type
-when the @code{-fvxt} option is specified.
+when the @samp{-fvxt} option is specified.
The form of this octal constant is
@example
where @var{octal-digits} is a nonempty string of characters in
the set @samp{01234567}.
-For example, the @code{-fvxt} option permits this:
+For example, the @samp{-fvxt} option permits this:
@example
PRINT *, "20
as a continuation character rather than
as the beginning of a comment
(as it does in any other column)
-when the @code{-fvxt} option is specified.
+when the @samp{-fvxt} option is specified.
The following program, when run, prints a message indicating
whether it is interpreted according to GNU Fortran (and Fortran 90)
Automatic conversion of numeric
expressions to @code{INTEGER(KIND=1)} in contexts such as:
-@itemize --
+@itemize @minus
@item
Array-reference indexes.
@item
These are humorously referred to as ``distensions'',
extensions that just plain look ugly in the harsh light of day.
-@emph{Note:} The @samp{-fugly} option, which currently serves
-as shorthand to enable all of the distensions below, is likely to
-be removed in a future version of @code{g77}.
-That's because it's likely new distensions will be added that
-conflict with existing ones in terms of assigning meaning to
-a given chunk of code.
-(Also, it's pretty clear that users should not use @samp{-fugly}
-as shorthand when the next release of @code{g77} might add a
-distension to that that causes their existing code, when recompiled,
-to behave differently---perhaps even fail to compile or run
-correctly.)
-
@menu
* Ugly Implicit Argument Conversion:: Disabled via @samp{-fno-ugly-args}.
* Ugly Assumed-Size Arrays:: Enabled via @samp{-fugly-assumed}.
Normally, for portability and improved diagnostics, @code{g77}
reserves distinct storage for a ``sibling'' of @samp{I}, used
only for @code{ASSIGN} statements to that variable (along with
-the corresponding assigned-@code{GOTO} and assigned-@samp{FORMAT}-I/O
+the corresponding assigned-@code{GOTO} and assigned-@code{FORMAT}-I/O
statements that reference the variable).
However, some code (that violates the ANSI FORTRAN 77 standard)
The @code{libg2c} library
shipped with any @code{g77} that warns
about invocation of a non-Y2K-compliant intrinsic
-has renamed the @samp{EXTERNAL} procedure names
+has renamed the @code{EXTERNAL} procedure names
of those intrinsics.
This is done so that
the @code{libg2c} implementations of these intrinsics
cannot be directly linked to
-as @samp{EXTERNAL} names
+as @code{EXTERNAL} names
(which normally would avoid the non-Y2K-intrinsic warning).
-The renamed forms of the @samp{EXTERNAL} names
+The renamed forms of the @code{EXTERNAL} names
of these renamed procedures
may be linked to
by appending the string @samp{_y2kbug}
CALL VXTIDATE_Y2KBUG (MM, DD, YY)
@end smallexample
-(Note that the @samp{EXTERNAL} statement
+(Note that the @code{EXTERNAL} statement
is not actually required,
since the modified names are not recognized as intrinsics
by the current version of @code{g77}.
But it is shown in this specific case,
for purposes of illustration.)
-The renaming of @samp{EXTERNAL} procedure names of these intrinsics
+The renaming of @code{EXTERNAL} procedure names of these intrinsics
causes unresolved references at link time.
For example, @samp{EXTERNAL DATE; CALL DATE(STR)}
is normally compiled by @code{g77}
as, in C, @samp{date_(&str, 20);}.
-This, in turn, links to the @samp{date_} procedure
-in the @samp{libE77} portion of @code{libg2c},
+This, in turn, links to the @code{date_} procedure
+in the @code{libE77} portion of @code{libg2c},
which purposely calls a nonexistent procedure
-named @samp{G77_date_y2kbuggy_0}.
+named @code{G77_date_y2kbuggy_0}.
The resulting link-time error is designed, via this name,
to encourage the programmer to look up the
index entries to this portion of the @code{g77} documentation.
-Generally, we recommend that the @samp{EXTERNAL} method
+Generally, we recommend that the @code{EXTERNAL} method
of invoking procedures in @code{libg2c}
@emph{not} be used.
When used, some of the correctness checking
is skipped.
In particular, it is probably better to use the
-@samp{INTRINSIC} method of invoking
+@code{INTRINSIC} method of invoking
non-Y2K-compliant procedures,
so anyone compiling the code
can quickly notice the potential Y2K problems
(invoking one of the intrinsics in question)
to an old library
might yield an unresolved reference
-to @samp{G77_date_y2kbug_0}.
-(The old library calls it @samp{G77_date_0}.)
+to @code{G77_date_y2kbug_0}.
+(The old library calls it @code{G77_date_0}.)
Similarly, linking previously-compiled code
to a new library
might yield an unresolved reference
-to @samp{G77_vxtidate_0}.
-(The new library calls it @samp{G77_vxtidate_y2kbug_0}.)
+to @code{G77_vxtidate_0}.
+(The new library calls it @code{G77_vxtidate_y2kbug_0}.)
The proper fix for the above problems
is to obtain the latest release of @code{g77}
@pindex f2c
@cindex cfortran.h
@cindex Netlib
-Even if you don't actually use it as a compiler, @samp{f2c} from
+Even if you don't actually use it as a compiler, @code{f2c} from
@uref{ftp://ftp.netlib.org/f2c/src}, can be a useful tool when you're
interfacing (linking) Fortran and C@.
@xref{f2c Skeletons and Prototypes,,Generating Skeletons and Prototypes with @code{f2c}}.
@code{f2c} program on your path.
Something else that might be useful is @samp{cfortran.h} from
-@uref{ftp://zebra/desy.de/cfortran}.
+@uref{ftp://zebra.desy.de/cfortran}.
This is a fairly general tool which
can be used to generate interfaces for calling in both directions
between Fortran and C@.
called from Fortran---should @samp{#include <g2c.h>} to define the C
versions of the Fortran types.
Don't assume Fortran @code{INTEGER} types
-correspond to C @samp{int}s, for instance; instead, declare them as
+correspond to C @code{int}s, for instance; instead, declare them as
@code{integer}, a type defined by @file{g2c.h}.
@file{g2c.h} is installed where @code{gcc} will find it by
default, assuming you use a copy of @code{gcc} compatible with
interface with an existing library---is to write a file (named, for
example, @file{fred.f}) of dummy Fortran
skeletons comprising just the declaration of the routine(s) and dummy
-arguments plus @samp{END} statements.
+arguments plus @code{END} statements.
Then run @code{f2c} on file @file{fred.f} to produce @file{fred.c}
into which you can edit
useful code, confident the calling sequence is correct, at least.
@samp{-P} option to generate C prototypes appropriate for calling the
Fortran.@footnote{The files generated like this can also be used for
inter-unit consistency checking of dummy and actual arguments, although
-the @samp{ftnchek} tool from @uref{ftp://ftp.netlib.org/fortran}
+the @code{ftnchek} tool from @uref{ftp://ftp.netlib.org/fortran}
or @uref{ftp://ftp.dsm.fordham.edu} is
probably better for this purpose.}
If the Fortran code containing any
@cindex statements, PROGRAM
When @code{g77} compiles a main program unit, it gives it the public
-procedure name @samp{MAIN__}.
+procedure name @code{MAIN__}.
The @code{libg2c} library has the actual @code{main()} procedure
as is typical of C-based environments, and
it is this procedure that performs some initial start-up
-activity and then calls @samp{MAIN__}.
+activity and then calls @code{MAIN__}.
Generally, @code{g77} and @code{libg2c} are designed so that you need not
include a main program unit written in Fortran in your program---it
The standard way to get around this problem is to set a break
point (a one-time, or temporary, break point will do) at
-the entrance to @samp{MAIN__}, and then run the program.
+the entrance to @code{MAIN__}, and then run the program.
A convenient way to do so is to add the @code{gdb} command
@example
Of course, if you really want to set a break point at some
other place in your program and just start the program
-running, without first breaking at @samp{MAIN__},
+running, without first breaking at @code{MAIN__},
that should work fine.
@node Procedures
properly supports Fortran-language debugging, including access
to members of @code{COMMON} areas.)
+Version 0.5.26 of @code{g77} is believed to provide correct and
+complete debug information for COMMON BLOCK and EQUIVALENCE items -
+hence the @samp{-fdebug-kludge} option has been disabled.
+
@xref{Code Gen Options,,Options for Code Generation Conventions},
for information on the @samp{-fdebug-kludge} option.
(In @code{gdb}, this is accomplished via @samp{set lang c} and
either @samp{set lang fortran} or @samp{set lang auto}.)
-@emph{Note:} Compiling with the @samp{-fno-emulate-complex} option
-avoids the debugging problem, but is known to cause other problems
-like compiler crashes and generation of incorrect code, so it is
-not recommended.
-
@node Arrays
@section Arrays (DIMENSION)
@cindex DIMENSION statement
so you can more easily change the actual numbers in the future.
The information below is culled from the definition
-of @samp{F_err} in @file{f/runtime/libI77/err.c} in the
+of @code{F_err} in @file{f/runtime/libI77/err.c} in the
@code{g77} source tree.
@smallexample
@menu
* Language Extensions:: Features used by Fortran code.
-* Compiler Options:: Features helpful during development.
+* Diagnostic Abilities:: Abilities to spot problems early.
+* Compiler Options:: Features helpful to accommodate legacy code, etc.
* Compiler Speed:: Speed of the compilation process.
* Program Speed:: Speed of the generated, optimized code.
* Ease of Debugging:: Debugging ease-of-use at the source level.
@node Language Extensions
@subsection Language Extensions
-@code{g77} offers several extensions to the Fortran language that @code{f2c}
-doesn't.
+@code{g77} offers several extensions to FORTRAN 77 language that @code{f2c}
+doesn't:
+
+@itemize @bullet
+@item
+Automatic arrays
+
+@item
+@code{CYCLE} and @code{EXIT}
+
+@item
+Construct names
+
+@item
+@code{SELECT CASE}
+
+@item
+@code{KIND=} and @code{LEN=} notation
+
+@item
+Semicolon as statement separator
+
+@item
+Constant expressions in @code{FORMAT} statements
+(such as @samp{FORMAT(I<J>)},
+where @samp{J} is a @code{PARAMETER} named constant)
+
+@item
+@code{MvBits} intrinsic
+
+@item
+@code{libU77} (Unix-compatibility) library,
+with routines known to compiler as intrinsics
+(so they work even when compiler options are used
+to change the interfaces used by Fortran routines)
+@end itemize
+
+@code{g77} also implements iterative @code{DO} loops
+so that they work even in the presence of certain ``extreme'' inputs,
+unlike @code{f2c}.
+@xref{Loops}.
+
+However, @code{f2c} offers a few that @code{g77} doesn't, such as:
+
+@itemize @bullet
+@item
+Intrinsics in @code{PARAMETER} statements
+
+@item
+Array bounds expressions (such as @samp{REAL M(N(2))})
+
+@item
+@code{AUTOMATIC} statement
+@end itemize
-However, @code{f2c} offers a few that @code{g77} doesn't, like
-fairly complete support for @code{INTEGER*2}.
It is expected that @code{g77} will offer some or all of these missing
features at some time in the future.
-(Version 0.5.18 of @code{g77} offers some rudimentary support for some
-of these features.)
+
+@node Diagnostic Abilities
+@subsection Diagnostic Abilities
+
+@code{g77} offers better diagnosis of problems in @code{FORMAT} statements.
+@code{f2c} doesn't, for example, emit any diagnostic for
+@samp{FORMAT(XZFAJG10324)},
+leaving that to be diagnosed, at run time, by
+the @code{libf2c} run-time library.
@node Compiler Options
@subsection Compiler Options
-@code{g77} offers a whole bunch of compiler options that @code{f2c} doesn't.
+@code{g77} offers compiler options that @code{f2c} doesn't,
+most of which are designed to more easily accommodate
+legacy code:
+
+@itemize @bullet
+@item
+Two that control the automatic appending of extra
+underscores to external names
+
+@item
+One that allows dollar signs (@samp{$}) in symbol names
+
+@item
+A variety that control acceptance of various
+``ugly'' constructs
+
+@item
+Several that specify acceptable use of upper and lower case
+in the source code
+
+@item
+Many that enable, disable, delete, or hide
+groups of intrinsics
-However, @code{f2c} offers a few that @code{g77} doesn't, like an
-option to generate code to check array subscripts at run time.
-It is expected that @code{g77} will offer some or all of these
-missing options at some time in the future.
+@item
+One to specify the length of fixed-form source lines
+(normally 72)
+
+@item
+One to specify the the source code is written in
+Fortran-90-style free-form
+@end itemize
+
+However, @code{f2c} offers a few that @code{g77} doesn't,
+like an option to have @code{REAL} default to @code{REAL*8}.
+It is expected that @code{g77} will offer all of the
+missing options pertinent to being a Fortran compiler
+at some time in the future.
@node Compiler Speed
@subsection Compiler Speed
were withdrawn as of @code{g77} version 0.5.23
due to their not being supported by @code{gcc} version 2.8.
-These options, which control the assumptions regarding aliasing
+These options control the assumptions regarding aliasing
(overlapping) of writes and reads to main memory (core) made
-by the @code{gcc} back end,
-might well be added back (in some form) in a future version
-of @code{gcc}.
-
-However, these options @emph{are} supported by @code{egcs}.
+by the @code{gcc} back end.
The information below still is useful, but applies to
only those versions of @code{g77} that support the
For several versions prior to 0.5.20, @code{g77} configured its
version of the @code{libf2c} run-time library so that one of
-its configuration macros, @samp{ALWAYS_FLUSH}, was defined.
+its configuration macros, @code{ALWAYS_FLUSH}, was defined.
This was done as a result of a belief that many programs expected
output to be flushed to the operating system (under UNIX, via
@xref{Always Flush Output}, for information on how to modify
the @code{g77} source tree so that a version of @code{libg2c}
-can be built and installed with the @samp{ALWAYS_FLUSH} macro defined.
+can be built and installed with the @code{ALWAYS_FLUSH} macro defined.
@node Large File Unit Numbers
@subsection Large File Unit Numbers
@code{libg2c}.
Normally, this range is 0 through 99, and the high end
of the range is controlled by a @code{libg2c} source-file
-macro named @samp{MXUNIT}.
+macro named @code{MXUNIT}.
If you can easily change your program to use unit numbers
in the range 0 through 99, you should do so.
Otherwise, see @ref{Larger File Unit Numbers}, for information on how
-to change @samp{MXUNIT} in @code{libg2c} so you can build and
+to change @code{MXUNIT} in @code{libg2c} so you can build and
install a new version of @code{libg2c} that supports the larger
unit numbers you need.
@cindex x86 floating-point
If your program depends on exact IEEE 754 floating-point handling it may
help on some systems---specifically x86 or m68k hardware---to use
-the @code{-ffloat-store} option or to reset the precision flag on the
-floating-point unit @xref{Optimize Options}.
+the @samp{-ffloat-store} option or to reset the precision flag on the
+floating-point unit.
+@xref{Optimize Options}.
However, it might be better simply to put the FPU into double precision
-mode and not take the performance hit of @code{-ffloat-store}. On x86
+mode and not take the performance hit of @samp{-ffloat-store}. On x86
and m68k GNU systems you can do this with a technique similar to that
-for turning on floating-point exceptions @xref{Floating-point Exception
-Handling}. The control word could be set to double precision by
-replacing the @code{__setfpucw} call with one like this:
+for turning on floating-point exceptions
+(@pxref{Floating-point Exception Handling}).
+The control word could be set to double precision by some code like this
+one:
@smallexample
- __setfpucw ((_FPU_DEFAULT & ~_FPU_EXTENDED) | _FPU_DOUBLE);
+#include <fpu_control.h>
+@{
+ fpu_control_t cw = (_FPU_DEFAULT & ~_FPU_EXTENDED) | _FPU_DOUBLE;
+ _FPU_SETCW(cw);
+@}
@end smallexample
(It is not clear whether this has any effect on the operation of the GNU
maths library, but we have no evidence of it causing trouble.)
Some targets (such as the Alpha) may need special options for full IEEE
-conformance @xref{Submodel Options,,Hardware Models and
-Configurations,gcc,Using and Porting GNU CC}.
+conformance.
+@xref{Submodel Options,,Hardware Models and Configurations,gcc,Using and Porting GNU CC}.
@node Inconsistent Calling Sequences
@subsection Inconsistent Calling Sequences
@cindex ix86 FPU stack
@cindex x86 FPU stack
Code containing inconsistent calling sequences in the same file is
-normally rejected @xref{GLOBALS}. (Use, say, @code{ftnchek} to ensure
-consistency across source files
-@c makeinfo 1.68 objects to the nested parens
-@ifinfo
-@xref{f2c Skeletons and Prototypes}.)
-@end ifinfo
-@ifnotinfo
+normally rejected---see @ref{GLOBALS}.
+(Use, say, @code{ftnchek} to ensure
+consistency across source files.
@xref{f2c Skeletons and Prototypes,,
-{Generating Skeletons and Prototypes with @code{f2c}}}.)
-@end ifnotinfo
+Generating Skeletons and Prototypes with @code{f2c}}.)
Mysterious errors, which may appear to be code generation problems, can
appear specifically on the x86 architecture with some such
@code{RECURSIVE} procedures or other means of explicitly
specifying that variables or arrays are automatic.
-@cindex -fugly option
-@cindex options, -fugly
-@item -fugly
-Fix the source code so that @samp{-fno-ugly} will work.
-Note that, for many programs, it is difficult to practically
-avoid using the features enabled via @samp{-fugly-init}, and these
-features pose the lowest risk of writing nonportable code, among the
-various ``ugly'' features.
-
@cindex -f@var{group}-intrinsics-hide option
@cindex options, -f@var{group}-intrinsics-hide
@item -f@var{group}-intrinsics-hide
@node Aligned Data
@subsection Aligned Data
+@cindex alignment
@cindex data, aligned
@cindex stack, aligned
@cindex aligned data
or uses @code{EQUIVALENCE} or different layouts
in ways that assume no padding is ever inserted by the compiler.
-@emph{Note:} @samp{-malign-double} applies only to
-statically-allocated data.
-Double-precision data on the stack can still
-cause problems due to misalignment.
-@xref{Aligned Data}.
-
@item
Ensure that @file{crt0.o} or @file{crt1.o}
on your system guarantees a 64-bit
@code{gcc}, and some of the relevant operating systems
(such as GNU/Linux).
+@cindex alignment testing
+@cindex testing alignment
+A package that tests the degree to which a Fortran compiler
+(such as @code{g77})
+aligns 64-bit floating-point variables and arrays
+is available at @uref{ftp://alpha.gnu.org/gnu/g77/align/}.
+
@node Prefer Automatic Uninitialized Variables
@subsection Prefer Automatic Uninitialized Variables
@node Use Submodel Options
@subsection Use Submodel Options
-@cindex Pentium optimizations
-@cindex optimization, for Pentium
-@cindex 586/686 CPUs
@cindex submodels
Using an appropriate @samp{-m} option to generate specific code for your
CPU may be worthwhile, though it may mean the executable won't run on
other versions of the CPU that don't support the same instruction set.
@xref{Submodel Options,,Hardware Models and Configurations,gcc,Using and
-Porting GNU CC}.
+Porting GNU CC}. For instance on an x86 system the compiler might have
+been built---as shown by @samp{g77 -v}---for the target
+@samp{i386-pc-linux-gnu}, i.e.@: an @samp{i386} CPU@. In that case to
+generate code best optimized for a Pentium you could use the option
+@samp{-march=pentium}.
-For recent CPUs that don't have explicit support in
-the released version of @code{gcc}, it may still be possible to get
-improvements.
-For instance, the flags recommended for 586/686
-(Pentium(Pro)) chips for building the Linux kernel are:
-
-@smallexample
--m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2
--fomit-frame-pointer
-@end smallexample
+For recent CPUs that don't have explicit support in the released version
+of @code{gcc}, it @emph{might} still be possible to get improvements
+with certain @samp{-m} options.
-@noindent @samp{-fomit-frame-pointer} will, however, inhibit debugging
-on x86 systems.
+@samp{-fomit-frame-pointer} can help performance on x86 systems and
+others. It will, however, inhibit debugging on the systems on which it
+is not turned on anyway by @samp{-O}.
@node Trouble
@chapter Known Causes of Trouble with GNU Fortran
directly from the @code{gcc} manual, with minor modifications
to tailor it to users of @code{g77}.
Anytime a bug seems to have more to do with the @code{gcc}
-portion of @code{g77},
-@xref{Trouble,,Known Causes of Trouble with GNU CC,
+portion of @code{g77}, see
+@ref{Trouble,,Known Causes of Trouble with GNU CC,
gcc,Using and Porting GNU CC}.)
@menu
of this manual.
However, users of Linux-based systems (such as GNU/Linux)
-should review @uref{http://www.bitwizard.nl/sig11}, a source
+should review @uref{http://www.bitwizard.nl/sig11/}, a source
of detailed information on diagnosing hardware problems,
by recognizing their common symptoms.
@subsection Nothing Happens
@cindex nothing happens
@cindex naming programs
-@cindex @samp{test} programs
-@cindex programs, @samp{test}
+@cindex @code{test} programs
+@cindex programs, @code{test}
It is occasionally reported that a ``simple'' program,
such as a ``Hello, World!'' program, does nothing when
it is run, even though the compiler reported no errors,
simple @code{PRINT} statement.
This most often happens because the program has been
-compiled and linked on a UNIX system and named @samp{test},
+compiled and linked on a UNIX system and named @code{test},
though other names can lead to similarly unexpected
run-time behavior on various systems.
Overflowing the bounds of an array---usually by writing beyond
the end of it---is one of two kinds of bug that often occurs
in Fortran code.
+(Compile your code with the @samp{-fbounds-check} option
+to catch many of these kinds of errors at program run time.)
The other kind of bug is a mismatch between the actual arguments
passed to a procedure and the dummy arguments as declared by that
data representing the placement of other data in memory (that is,
pointers, such as the placement of stack frames in memory).
-Plans call for improving @code{g77} so that it can offer the
+@code{g77} now offers the
ability to catch and report some of these problems at compile, link, or
run time, such as by generating code to detect references to
-beyond the bounds of an array, or checking for agreement between
-calling and called procedures.
+beyond the bounds of most arrays (except assumed-size arrays),
+and checking for agreement between calling and called procedures.
+Future improvements are likely to be made in the procedure-mismatch area,
+at least.
In the meantime, finding and fixing the programming
bugs that lead to these behaviors is, ultimately, the user's
Since @samp{0.2} in the program is a single-precision value, it
is converted to double precision (still in binary notation)
before being converted back to decimal.
-The conversion to binary appends _binary_ zero digits to the
+The conversion to binary appends @emph{binary} zero digits to the
original value---which, again, is an inexact approximation of
0.2---resulting in an approximation that is much less exact
than is connoted by the use of double precision.
A useful source of information on floating-point computation is David
Goldberg, `What Every Computer Scientist Should Know About
Floating-Point Arithmetic', Computing Surveys, 23, March 1991, pp.@:
-5--48.
+5-48.
An online version is available at
-@uref{http://docs.sun.com},
+@uref{http://docs.sun.com/},
and there is a supplemented version, in PostScript form, at
@uref{http://www.validgh.com/goldberg/paper.ps}.
Information related to the IEEE 754
floating-point standard by a leading light can be found at
-@uref{http://http.cs.berkeley.edu/%7Ewkahan/ieee754status};
+@uref{http://http.cs.berkeley.edu/%7Ewkahan/ieee754status/};
see also slides from the short course referenced from
@uref{http://http.cs.berkeley.edu/%7Efateman/}.
@uref{http://www.linuxsupportline.com/%7Ebillm/} has a brief
* Better Source Model::
* Fortran 90 Support::
* Intrinsics in PARAMETER Statements::
+* Arbitrary Concatenation::
* SELECT CASE on CHARACTER Type::
* RECURSIVE Keyword::
* Popular Non-standard Types::
* Array Bounds Expressions::
* POINTER Statements::
* Sensible Non-standard Constructs::
+* READONLY Keyword::
* FLUSH Statement::
* Expressions in FORMAT Statements::
* Explicit Assembler Code::
* Suppressing Space Padding::
* Fortran Preprocessor::
* Bit Operations on Floating-point Data::
+* Really Ugly Character Assignments::
New facilities:
* POSIX Standard::
* Large Automatic Arrays::
* Support for Threads::
* Increasing Precision/Range::
+* Enabling Debug Lines::
Better diagnostics:
+* Better Warnings::
* Gracefully Handle Sensible Bad Code::
* Non-standard Conversions::
* Non-standard Intrinsics::
Run-time facilities:
* Uninitialized Variables at Run Time::
-* Bounds Checking at Run Time::
* Portable Unformatted Files::
+* Better List-directed I/O::
+* Default to Console I/O::
Debugging:
* Labels Visible to Debugger::
accidentally writing fixed-form source code into and beyond
column 73.
So, maybe the users of old code would be able to more easily handle
-having to specify, say, a @code{-Wno-col73to80} option.
+having to specify, say, a @samp{-Wno-col73to80} option.
@node Fortran 90 Support
@subsection Fortran 90 Support
such a facility, @code{g77} will likely use that facility
in implementing this feature soon afterwards.
+@node Arbitrary Concatenation
+@subsection Arbitrary Concatenation
+@cindex concatenation
+@cindex CHARACTER*(*)
+@cindex run-time, dynamic allocation
+
+@code{g77} doesn't support arbitrary operands for concatenation
+in contexts where run-time allocation is required.
+For example:
+
+@smallexample
+SUBROUTINE X(A)
+CHARACTER*(*) A
+CALL FOO(A // 'suffix')
+@end smallexample
+
@node SELECT CASE on CHARACTER Type
@subsection @code{SELECT CASE} on @code{CHARACTER} Type
bug report with an explanation, so we can consider
fixing @code{g77} just for cases like yours.
+@node READONLY Keyword
+@subsection @code{READONLY} Keyword
+@cindex READONLY
+
+Support for @code{READONLY}, in @code{OPEN} statements,
+requires @code{libg2c} support,
+to make sure that @samp{CLOSE(@dots{},STATUS='DELETE')}
+does not delete a file opened on a unit
+with the @code{READONLY} keyword,
+and perhaps to trigger a fatal diagnostic
+if a @code{WRITE} or @code{PRINT}
+to such a unit is attempted.
+
+@emph{Note:} It is not sufficient for @code{g77} and @code{libg2c}
+(its version of @code{libf2c})
+to assume that @code{READONLY} does not need some kind of explicit support
+at run time,
+due to UNIX systems not (generally) needing it.
+@code{g77} is not just a UNIX-based compiler!
+
+Further, mounting of non-UNIX filesystems on UNIX systems
+(such as via NFS)
+might require proper @code{READONLY} support.
+
+@cindex SHARED
+(Similar issues might be involved with supporting the @code{SHARED}
+keyword.)
+
@node FLUSH Statement
@subsection @code{FLUSH} Statement
@cindex automatic variables
@cindex variables, automatic
-@code{g77} doesn't support the @code{AUTOMATIC} keyword that
+@code{g77} doesn't support the @code{AUTOMATIC} statement that
@code{f2c} does.
-It is not yet clear exactly what this statement would achieve.
-The semantic equivalent would be provided by @code{RECURSIVE}
-combined with lack of @code{SAVE}.
-In that sense, perhaps all it would provide is an
-overriding of an unadorned (blanket) @code{SAVE} statement
-for specific variables.
+@code{AUTOMATIC} would identify a variable or array
+as not being @code{SAVE}'d, which is normally the default,
+but which would be especially useful for code that, @emph{generally},
+needed to be compiled with the @samp{-fno-automatic} option.
+
+@code{AUTOMATIC} also would serve as a hint to the compiler that placing
+the variable or array---even a very large array--on the stack is acceptable.
+
+@code{AUTOMATIC} would not, by itself, designate the containing procedure
+as recursive.
-It might also serve as a hint to the compiler that placing
-even a very large array on the stack is acceptable.
+@code{AUTOMATIC} should work syntactically like @code{SAVE},
+in that @code{AUTOMATIC} with no variables listed should apply to
+all pertinent variables and arrays
+(which would not include common blocks or their members).
-Perhaps it should disallow @code{DATA}
-or other specification of any initial values
-for affected variables as well.
+Variables and arrays denoted as @code{AUTOMATIC}
+would not be permitted to be initialized via @code{DATA}
+or other specification of any initial values,
+requiring explicit initialization,
+such as via assignment statements.
+
+@cindex UNSAVE
+@cindex STATIC
+Perhaps @code{UNSAVE} and @code{STATIC},
+as strict semantic opposites to @code{SAVE} and @code{AUTOMATIC},
+should be provided as well.
@node Suppressing Space Padding
@subsection Suppressing Space Padding of Source Lines
END
@end smallexample
+@node Really Ugly Character Assignments
+@subsection Really Ugly Character Assignments
+
+An option such as @samp{-fugly-char} should be provided
+to allow
+
+@smallexample
+REAL*8 A1
+DATA A1 / '12345678' /
+@end smallexample
+
+and:
+
+@smallexample
+REAL*8 A1
+A1 = 'ABCDEFGH'
+@end smallexample
+
@node POSIX Standard
@subsection @code{POSIX} Standard
be invoked at startup using @code{gcc}'s @code{constructor} attribute.
For example, just compiling and linking the following C code with your
program will turn on exception trapping for the ``common'' exceptions
-on an x86-based GNU system:
+on a GNU system using glibc 2.2 or newer:
@smallexample
-#include <fpu_control.h>
+#define _GNU_SOURCE 1
+#include <fenv.h>
static void __attribute__ ((constructor))
trapfpe ()
@{
- __setfpucw (_FPU_DEFAULT &
- ~(_FPU_MASK_IM | _FPU_MASK_ZM | _FPU_MASK_OM));
+ /* Enable some exceptions. At startup all exceptions are masked. */
+
+ feenableexcept (FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW);
@}
@end smallexample
@smallexample
gcc -o libtrapfpe.a trapfpe.c
@end smallexample
-and then use it by adding @code{-trapfpe} to the @code{g77} command line
+and then use it by adding @samp{-trapfpe} to the @code{g77} command line
when linking.
@node Nonportable Conversions
quietly accept.
Some of these conversions are accepted by @code{g77}
-when the @samp{-fugly} option is specified.
+when the @samp{-fugly-logint} option is specified.
Perhaps it should accept more or all of them.
@node Large Automatic Arrays
processors).
A package such as PVM might help here.
+@node Enabling Debug Lines
+@subsection Enabling Debug Lines
+@cindex debug line
+@cindex comment line, debug
+
+An option such as @samp{-fdebug-lines} should be provided
+to turn fixed-form lines beginning with @samp{D}
+to be treated as if they began with a space,
+instead of as if they began with a @samp{C}
+(as comment lines).
+
+@node Better Warnings
+@subsection Better Warnings
+
+Because of how @code{g77} generates code via the back end,
+it doesn't always provide warnings the user wants.
+Consider:
+
+@smallexample
+PROGRAM X
+PRINT *, A
+END
+@end smallexample
+
+Currently, the above is not flagged as a case of
+using an uninitialized variable,
+because @code{g77} generates a run-time library call that looks,
+to the GBE, like it might actually @emph{modify} @samp{A} at run time.
+(And, in fact, depending on the previous run-time library call,
+it would!)
+
+Fixing this requires one of the following:
+
+@itemize @bullet
+@item
+Switch to new library, @code{libg77}, that provides
+a more ``clean'' interface,
+vis-a-vis input, output, and modified arguments,
+so the GBE can tell what's going on.
+
+This would provide a pretty big performance improvement,
+at least theoretically, and, ultimately, in practice,
+for some types of code.
+
+@item
+Have @code{g77} pass a pointer to a temporary
+containing a copy of @samp{A},
+instead of to @samp{A} itself.
+The GBE would then complain about the copy operation
+involving a potentially uninitialized variable.
+
+This might also provide a performance boost for some code,
+because @samp{A} might then end up living in a register,
+which could help with inner loops.
+
+@item
+Have @code{g77} use a GBE construct similar to @code{ADDR_EXPR}
+but with extra information on the fact that the
+item pointed to won't be modified
+(a la @code{const} in C).
+
+Probably the best solution for now, but not quite trivial
+to implement in the general case.
+Worth considering after @code{g77} 0.6 is considered
+pretty solid.
+@end itemize
+
@node Gracefully Handle Sensible Bad Code
@subsection Gracefully Handle Sensible Bad Code
Note that use of the options @samp{-O -Wuninitialized} can catch
many such bugs at compile time.
-@node Bounds Checking at Run Time
-@subsection Bounds Checking at Run Time
-
-@code{g77} should offer run-time bounds-checking of array/subscript references
-in a fashion similar to @code{f2c}.
-
-Note that @code{g77} already warns about references to out-of-bounds
-elements of arrays when it detects these at compile time.
-
@node Portable Unformatted Files
@subsection Portable Unformatted Files
format.) A future @code{g77} runtime library should use such
techniques.
+@node Better List-directed I/O
+@subsection Better List-directed I/O
+
+Values output using list-directed I/O
+(@samp{PRINT *, R, D})
+should be written with a field width, precision, and so on
+appropriate for the type (precision) of each value.
+
+(Currently, no distinction is made between single-precision
+and double-precision values
+by @code{libf2c}.)
+
+It is likely this item will require the @code{libg77} project
+to be undertaken.
+
+In the meantime, use of formatted I/O is recommended.
+While it might be of little consolation,
+@code{g77} does support @samp{FORMAT(F<WIDTH>.4)}, for example,
+as long as @samp{WIDTH} is defined as a named constant
+(via @code{PARAMETER}).
+That at least allows some compile-time specification
+of the precision of a data type,
+perhaps controlled by preprocessing directives.
+
+@node Default to Console I/O
+@subsection Default to Console I/O
+
+The default I/O units,
+specified by @samp{READ @var{fmt}},
+@samp{READ (UNIT=*)},
+@samp{WRITE (UNIT=*)}, and
+@samp{PRINT @var{fmt}},
+should not be units 5 (input) and 6 (output),
+but, rather, unit numbers not normally available
+for use in statements such as @code{OPEN} and @code{CLOSE}.
+
+Changing this would allow a program to connect units 5 and 6
+to files via @code{OPEN},
+but still use @samp{READ (UNIT=*)} and @samp{PRINT}
+to do I/O to the ``console''.
+
+This change probably requires the @code{libg77} project.
+
@node Labels Visible to Debugger
@subsection Labels Visible to Debugger
@cindex logical expressions, comparing
Use of @code{.EQ.} and @code{.NE.} on @code{LOGICAL} operands
-is not supported, except via @samp{-fugly}, which is not
+is not supported, except via @samp{-fugly-logint}, which is not
recommended except for legacy code (where the behavior expected
by the @emph{code} is assumed).
you, without knowing more context, whether the @samp{&} and @samp{-}
operators are infix (binary) or unary!)
+Most dangerous of all is the fact that,
+even assuming consensus on its meaning,
+an expression like @samp{L.AND.M.EQ.N},
+if it is the result of a typographical error,
+doesn't @emph{look} like it has such a typo.
+Even experienced Fortran programmers would not likely notice that
+@samp{L.AND.M.EQV.N} was, in fact, intended.
+
+So, this is a prime example of a circumstance in which
+a quality compiler diagnoses the code,
+instead of leaving it up to someone debugging it
+to know to turn on special compiler options
+that might diagnose it.
+
@node Order of Side Effects
@subsection Order of Side Effects
@cindex side effects, order of evaluation
which is used during the build of @code{gcc} to
build a list of all options that are accepted by
at least one language's compiler.
-This list goes into the @samp{lang_options} array
+This list goes into the @code{documented_lang_options} array
in @file{gcc/toplev.c}, which uses this array to
determine whether a particular option should be
offered to the linked-in front end for processing
-by calling @samp{lang_option_decode}, which, for
+by calling @code{lang_option_decode}, which, for
@code{g77}, is in @file{@value{path-g77}/com.c} and just
-calls @samp{ffe_decode_option}.
+calls @code{ffe_decode_option}.
If the linked-in front end ``rejects'' a
particular option passed to it, @file{toplev.c}
This allows commands like @samp{gcc -fno-asm foo.c bar.f}
to work, even though Fortran compilation does
not currently support the @samp{-fno-asm} option;
-even though the @code{f771} version of @samp{lang_decode_option}
+even though the @code{f771} version of @code{lang_decode_option}
rejects @samp{-fno-asm}, @file{toplev.c} doesn't
produce a diagnostic because some other language (C)
does accept it.
possible.
Code that processes Fortran options is found in
-@file{@value{path-g77}/top.c}, function @samp{ffe_decode_option}.
+@file{@value{path-g77}/top.c}, function @code{ffe_decode_option}.
This code needs to check positive and negative forms
of each option.
in the @code{g77} FFE, are defined in @file{@value{path-g77}/top.h}.
@emph{Compiler options} are listed in @file{gcc/toplev.c}
-in the array @samp{f_options}.
-An option not listed in @samp{lang_options} is
-looked up in @samp{f_options} and handled from there.
+in the array @code{f_options}.
+An option not listed in @code{lang_options} is
+looked up in @code{f_options} and handled from there.
The defaults for compiler options are set in the
global definitions for the corresponding variables,
You can set different defaults for @emph{Fortran-oriented}
or @emph{Fortran-reticent} compiler options by changing
-the way @code{f771} handles the @samp{-fset-g77-defaults}
+the source code of @code{g77} and rebuilding.
+How to do this depends on the version of @code{g77}:
+
+@table @code
+@item G77 0.5.24 (EGCS 1.1)
+@itemx G77 0.5.25 (EGCS 1.2 - which became GCC 2.95)
+Change the @code{lang_init_options} routine in @file{gcc/gcc/f/com.c}.
+
+(Note that these versions of @code{g77}
+perform internal consistency checking automatically
+when the @samp{-fversion} option is specified.)
+
+@item G77 0.5.23
+@itemx G77 0.5.24 (EGCS 1.0)
+Change the way @code{f771} handles the @samp{-fset-g77-defaults}
option, which is always provided as the first option when
called by @code{g77} or @code{gcc}.
-This code is in @samp{ffe_decode_options} in @file{@value{path-g77}/top.c}.
+This code is in @code{ffe_decode_options} in @file{@value{path-g77}/top.c}.
Have it change just the variables that you want to default
to a different setting for Fortran compiles compared to
compiles of other languages.
even when the user has not explicitly specified them.
Other ``internal'' options such as @samp{-quiet} also
are passed via this mechanism.
+@end table
@node Projects
@chapter Projects
@itemize @bullet
@item
-Improve @samp{malloc} package and its uses to specify more info about
+Improve @code{malloc} package and its uses to specify more info about
memory pools and, where feasible, use obstacks to implement them.
@item
@item
Throughout @code{g77}, don't pass line/column pairs where
-a simple @samp{ffewhere} type, which points to the error as much as is
-desired by the configuration, will do, and don't pass @samp{ffelexToken} types
-where a simple @samp{ffewhere} type will do.
+a simple @code{ffewhere} type, which points to the error as much as is
+desired by the configuration, will do, and don't pass @code{ffelexToken} types
+where a simple @code{ffewhere} type will do.
Then, allow new default
-configuration of @samp{ffewhere} such that the source line text is not
+configuration of @code{ffewhere} such that the source line text is not
preserved, and leave it to things like Emacs' next-error function
to point to them (now that @samp{next-error} supports column,
or, perhaps, character-offset, numbers).
@item
When doing @samp{CHAR_VAR = CHAR_FUNC(@dots{})},
and it's clear that types line up
-and @samp{CHAR_VAR} is addressable or not a @samp{VAR_DECL},
+and @samp{CHAR_VAR} is addressable or not a @code{VAR_DECL},
make @samp{CHAR_VAR}, not a
temporary, be the receiver for @samp{CHAR_FUNC}.
(This is now done for @code{COMPLEX} variables.)
@code{gcc} rather than @code{f2c} calling conventions.)
@item
-Do something useful with @samp{doiter} references where possible.
+Do something useful with @code{doiter} references where possible.
For example, @samp{CALL FOO(I)} cannot modify @samp{I} if within
a @code{DO} loop that uses @samp{I} as the
iteration variable, and the back end might find that info useful
It is not worth repeating them here.
@item
-@cindex concatenation
-@cindex CHARACTER*(*)
-@cindex run-time, dynamic allocation
-Support arbitrary operands for concatenation, even in contexts where
-run-time allocation is required.
-For example:
-
-@smallexample
-SUBROUTINE X(A)
-CHARACTER*(*) A
-CALL FOO(A // 'suffix')
-@end smallexample
-
-@item
Consider adding a @code{NUMERIC} type to designate typeless numeric constants,
named and unnamed.
The idea is to provide a forward-looking, effective
@itemize @bullet
@item
-Switch to using @samp{REAL_VALUE_TYPE} to represent floating-point constants
+Switch to using @code{REAL_VALUE_TYPE} to represent floating-point constants
exclusively so the target float format need not be required.
This
means changing the way @code{g77} handles initialization of aggregate areas
Much of this should be done only after the redesign planned for
0.6 is complete.
+@xref{Front End}, which contains some information
+on @code{g77} internals.
+
@node Internals Improvements
@section Internals Improvements
to achieve desired implementation dialect via @file{proj.h}.
@item
-Clean up used tokens and @samp{ffewhere}s in @samp{ffeglobal_terminate_1}.
+Clean up used tokens and @code{ffewhere}s in @code{ffeglobal_terminate_1}.
@item
-Replace @file{sta.c} @samp{outpooldisp} mechanism with @samp{malloc_pool_use}.
+Replace @file{sta.c} @code{outpooldisp} mechanism with @code{malloc_pool_use}.
@item
-Check for @samp{opANY} in more places in @file{com.c}, @file{std.c},
+Check for @code{opANY} in more places in @file{com.c}, @file{std.c},
and @file{ste.c}, and get rid of the @samp{opCONVERT(opANY)} kludge
(after determining if there is indeed no real need for it).
in the code@dots{}uh@dots{}in the code.
@item
-Some @samp{ffebld_new} calls (those outside of @file{ffeexpr.c} or
-inside but invoked via paths not involving @samp{ffeexpr_lhs} or
-@samp{ffeexpr_rhs}) might be creating things
+Some @code{ffebld_new} calls (those outside of @file{ffeexpr.c} or
+inside but invoked via paths not involving @code{ffeexpr_lhs} or
+@code{ffeexpr_rhs}) might be creating things
in improper pools, leading to such things staying around too long or
(doubtful, but possible and dangerous) not long enough.
@item
-Some @samp{ffebld_list_new} (or whatever) calls might not be matched by
-@samp{ffebld_list_bottom} (or whatever) calls, which might someday matter.
+Some @code{ffebld_list_new} (or whatever) calls might not be matched by
+@code{ffebld_list_bottom} (or whatever) calls, which might someday matter.
(It definitely is not a problem just yet.)
@item
Probably not doing clean things when we fail to @code{EQUIVALENCE} something
due to alignment/mismatch or other problems---they end up without
-@samp{ffestorag} objects, so maybe the backend (and other parts of the front
-end) can notice that and handle like an @samp{opANY} (do what it wants, just
+@code{ffestorag} objects, so maybe the backend (and other parts of the front
+end) can notice that and handle like an @code{opANY} (do what it wants, just
don't complain or crash).
Most of this seems to have been addressed
by now, but a code review wouldn't hurt.
@item
When @code{FUNCTION} and @code{ENTRY} point types disagree (@code{CHARACTER}
lengths, type classes, and so on),
-@samp{ANY}-ize the offending @code{ENTRY} point and any @emph{new} dummies
+@code{ANY}-ize the offending @code{ENTRY} point and any @emph{new} dummies
it specifies.
@item
is processed in the context of executable, not specification,
statements.)
@end itemize
+
+@include ffe.texi
+
@end ifset
@ifset USING
* INTGLOB:: Intrinsic also used as name of global.
* LEX:: Various lexer messages
* GLOBALS:: Disagreements about globals.
-* LINKFAIL:: When linking @samp{f771} fails.
+* LINKFAIL:: When linking @code{f771} fails.
* Y2KBAD:: Use of non-Y2K-compliant intrinsic.
@end menu
@itemize @bullet
@item
Change it to @samp{DBLE(@var{expr})} (if @var{intrinsic} is
-@samp{REAL}) or @samp{DIMAG(@var{expr})} (if @var{intrinsic}
-is @samp{AIMAG})
+@code{REAL}) or @samp{DIMAG(@var{expr})} (if @var{intrinsic}
+is @code{AIMAG})
if it expected the Fortran 90 interpretation.
This assumes @var{expr} is @code{COMPLEX(KIND=2)}---if it is
CALL XYZZY_RESET
@end smallexample
-However, that leaves the first @samp{C} in the @samp{CALL}
+However, that leaves the first @samp{C} in the @code{CALL}
statement in column 6, making it a comment line, which is
not really what the author intended, and which is likely
to result in one of the above-listed diagnostics.
@emph{Replacing} the @samp{C} in column 1 with a space
-is the proper change to make, to ensure the @samp{CALL}
+is the proper change to make, to ensure the @code{CALL}
keyword starts in or after column 7.
Another common mistake like this is to forget that fixed-form
this problem,
which occurs only in releases of @code{g77}
based on @code{gcc}.
-(It does not occur in @code{egcs}.)
+(It did not occur in @code{egcs}.)
On AIX 4.1, @code{g77} might not build with the native (non-GNU) tools
due to a linker bug in coping with the @samp{-bbigtoc} option which