The following program is invalid but accepted by gfortran, at runtime the program fails. Other compilers: - NAG f95 compiles this and does not fail - g95: Error: Circular specification in variable 'a' at (1) - ifort: fortcom: Error: x.f90, line 11: The data types of the argument(s) are invalid. [LEN] character(len(a)),dimension(1) :: a -----------------^ fortcom: Error: x.f90, line 11: This name has already been used in a specification expression. [A] character(len(a)),dimension(1) :: a -------------------------------------^
This is disallowed by 7.1.6.2 "If a specification expression includes a reference to an inquiry function for a type parameter or an array bound of an entity specified in the same specification-part, the type parameter or array bound shall be specified in a prior specification of the specification-part. The prior specification may be to the left of the inquiry function reference in the same statement. If a specification expression includes a reference to the value of an element of an array specified in the same specification-part, the array shall be completely specified in prior declarations." See http://gcc.gnu.org/ml/fortran/2007-05/msg00395.html for the dump. program me implicit none call gee( [f(3)] ) contains function f(k) result(i) integer :: k character(len=k) :: i i = '1234' end function subroutine gee(a) character(len(a)),dimension(1) :: a if(len(a) /= 3) stop 'abort' if(a(1) /= '123') stop 'abort' end subroutine gee end program me -- Summary: Accepts invalid character(len(a)),dimension(1) :: a Product: gcc Version: 4.3.0 Status: UNCONFIRMED Keywords: accepts-invalid 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=32095