Errors are diagnostic messages that report that the GNU Fortran compiler cannot compile the relevant piece of source code. The compiler will continue to process the program in an attempt to report further errors to aid in debugging, but will not produce any compiled output.
Warnings are diagnostic messages that report constructions which are not inherently erroneous but which are risky or suggest there is likely to be a bug in the program. Unless -Werror
is specified, they do not prevent compilation of the program.
You can request many specific warnings with options beginning -W
, for example -Wimplicit
to request warnings on implicit declarations. Each of these specific warning options also has a negative form beginning -Wno-
to turn off warnings; for example, -Wno-implicit
. This manual lists only one of the two forms, whichever is not the default.
These options control the amount and kinds of errors and warnings produced by GNU Fortran:
-fmax-errors=
n
-fsyntax-only
-pedantic
-pedantic
also applies to C-language constructs where they occur in GNU Fortran source files, such as use of ‘\e
’ in a character constant within a directive like #include
. Valid Fortran 95 programs should compile properly with or without this option. However, without this option, certain GNU extensions and traditional Fortran features are supported as well. With this option, many of them are rejected.
Some users try to use -pedantic
to check programs for conformance. They soon find that it does not do quite what they want—it finds some nonstandard practices, but not all. However, improvements to GNU Fortran in this area are welcome.
This should be used in conjunction with -std=f95
, -std=f2003
or -std=f2008
.
-pedantic-errors
-pedantic
, except that errors are produced rather than warnings. -Wall
-Waliasing
, -Wampersand
, -Wconversion
, -Wsurprising
, -Wc-binding-type
, -Wintrinsics-std
, -Wtabs
, -Wintrinsic-shadow
, -Wline-truncation
, -Wtarget-lifetime
, -Winteger-division
, -Wreal-q-constant
and -Wunused
. -Waliasing
INTENT(IN)
and a dummy argument with INTENT(OUT)
in a call with an explicit interface. The following example will trigger the warning.
interface subroutine bar(a,b) integer, intent(in) :: a integer, intent(out) :: b end subroutine end interface integer :: a call bar(a,a)
-Wampersand
-Wampersand
, -pedantic
, -std=f95
, -std=f2003
and -std=f2008
. Note: With no ampersand given in a continued character constant, GNU Fortran assumes continuation at the first non-comment, non-whitespace character after the ampersand that initiated the continuation. -Warray-temporaries
-Wc-binding-type
ISO_C_Binding
module. This option is implied by -Wall
. -Wcharacter-truncation
-Wline-truncation
-Wall
. For free-form source code, the default is -Werror=line-truncation
such that truncations are reported as error. -Wconversion
-Wall
. -Wconversion-extra
-Wconversion
. -Wextra
-Wcompare-reals
and -Wunused-parameter
. -Wimplicit-interface
-Wimplicit-procedure
EXTERNAL
. -Winteger-division
-Wintrinsics-std
gfortran
finds a procedure named like an intrinsic not available in the currently selected standard (with -std
) and treats it as EXTERNAL
procedure because of this. -fall-intrinsics
can be used to never trigger this behavior and always link to the intrinsic regardless of the selected standard. -Wreal-q-constant
q
exponent-letter. -Wsurprising
This currently produces a warning under the following circumstances:
-pedantic
or standard-conforming mode is enabled, this is an error. CHARACTER
variable is declared with negative length. -Wtabs
-Wtabs
will cause a warning to be issued if a tab is encountered. Note, -Wtabs
is active for -pedantic
, -std=f95
, -std=f2003
, -std=f2008
, -std=f2008ts
and -Wall
. -Wunderflow
-Wintrinsic-shadow
EXTERNAL
or INTRINSIC
declaration might be needed to get calls later resolved to the desired intrinsic/procedure. This option is implied by -Wall
. -Wuse-without-only
USE
statement has no ONLY
qualifier and thus implicitly imports all public entities of the used module. -Wunused-dummy-argument
-Wall
. -Wunused-parameter
gcc
's meaning of -Wunused-parameter
, gfortran
's implementation of this option does not warn about unused dummy arguments (see -Wunused-dummy-argument
), but about unused PARAMETER
values. -Wunused-parameter
is implied by -Wextra
if also -Wunused
or -Wall
is used. -Walign-commons
gfortran
warns about any occasion of variables being padded for proper alignment inside a COMMON
block. This warning can be turned off via -Wno-align-commons
. See also -falign-commons
. -Wfunction-elimination
-ffrontend-optimize
option. -Wrealloc-lhs
(:,:,:)
) for the variable on the left-hand side to prevent the reallocation check. Note that in some cases the warning is shown, even if the compiler will optimize reallocation checks away. For instance, when the right-hand side contains the same variable multiplied by a scalar. See also -frealloc-lhs
. -Wrealloc-lhs-all
-Wcompare-reals
-Wextra
. -Wtarget-lifetime
-Wall
. -Wzerotrip
DO
loop is known to execute zero times at compile time. This option is implied by -Wall
. -Werror
See Options to Request or Suppress Errors and Warnings, for information on more options offered by the GBE shared by gfortran
, gcc
and other GNU compilers.
Some of these have no effect when compiling programs written in Fortran.
© Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
https://gcc.gnu.org/onlinedocs/gcc-6.3.0/gfortran/Error-and-Warning-Options.html