4.3 Options to Request or Suppress Warnings
Warnings are diagnostic messages that report constructions which
are not inherently erroneous but which are risky or suggest there
might have been an error.
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 warnings produced by GNU
- Check the code for syntax errors, but don't do anything beyond that.
- Issue warnings for uses of extensions to FORTRAN 95.
-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
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 gfortran in this area are welcome.
This should be used in conjunction with -std=std.
- Like -pedantic, except that errors are produced rather than
- Inhibit all warning messages.
- Enables commonly used warning options pertaining to usage that
we recommend avoiding and that we believe are easy to avoid. This currently
includes -Wunused-labels, -Waliasing, -Wampersand,
- Warn about possible aliasing of dummy arguments. Specifically, it warns
if the same actual argument is associated with a dummy argument with
intent(in) and a dummy argument with
intent(out) in a call
with an explicit interface.
The following example will trigger the warning.
integer, intent(in) :: a
integer, intent(out) :: b
integer :: a
- Warn about missing ampersand in continued character literals. The warning is
given with -Wampersand, -pedantic, and -std=f95.
Note: With no ampersand given in a continued character literal, gfortran
assumes continuation at the first non-comment, non-whitespace character.
- Warn about implicit conversions between different types.
- Warn about when procedure are called without an explicit interface.
Note this only checks that an explicit interface is present. It does not
check that the declared interfaces are consistent across program units.
- Warn if the user tries to use an intrinsic that does not belong to the
standard the user has chosen via the -std option.
- Produce a warning when “suspicious” code constructs are encountered.
While technically legal these usually indicate that an error has been made.
This currently produces a warning under the following circumstances:
- An INTEGER SELECT construct has a CASE that can never be matched as its
lower value is greater than its upper value.
- A LOGICAL SELECT construct has three CASE statements.
- Produce a warning when numerical constant expressions are
encountered, which yield an UNDERFLOW during compilation.
- Warn whenever a label is defined but never referenced.
- Turns all warnings into errors.
- Turns on “extra warnings” and, if optimization is specified
via -O, the -Wuninitialized option.
(This might change in future versions of gfortran
See Options to Request or Suppress 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.