[Bug fortran/29813] New: -std=F95/F2003: Warn or error when using a non-declared variable with implicit none

burnus at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Mon Nov 13 10:01:00 GMT 2006


The following program is invalid as "n" needs to be declared as integer before
it is used.

gfortran -Wall -W -c -pedantic -std=f95, however, does compile it without any
warning or error.
This is detected by NAG f95 (error), but compiles with ifort, g95 and sunf95
without any warning or error (not all options tried).

subroutine test(n,array)
  implicit none
  real    :: array(n)
  integer :: n
end subroutine test

The relevant section of the standard is:

F2003, 7.1.6 (Specification expression), pg 126
F95, 7.1.6.2 (Specification expression), pg 96

"A variable in a specification expression shall have its type and type
parameters, if any, specified by a previous declaration in the scoping
unit, by the implicit typing rules in effect for the scoping unit, or by
host association. If a variable in a specification expression is typed
by the implicit typing rules, its appearance in any subsequent type
declaration statement shall confirm the implicit type and type
parameters".


-- 
           Summary: -std=F95/F2003: Warn or error when using a non-declared
                    variable with implicit none
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29813



More information about the Gcc-bugs mailing list