https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80666

            Bug ID: 80666
           Summary: character length parameter fails if declaration order
                    incorrect
           Product: gcc
           Version: 6.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kloedej at knmi dot nl
  Target Milestone: ---

For gfortran v.6.3.1 (on Fedora 25) I noticed that this example code:

subroutine test_arg_order(key,keylen)
  implicit none
  character*(keylen), intent(in) :: key
  integer, intent(in)            :: keylen
end subroutine test_arg_order

gives the error:

>gfortran -c test.F90
test.F90:3:13:

   character*(keylen), intent(in) :: key
             1
Error: Scalar INTEGER expression expected at (1)
test.F90:1:29:

 subroutine test_arg_order(key,keylen)
                             1
Error: Symbol ‘key’ at (1) has no IMPLICIT type
>

But if the order of declarations of the parameters is reversed in the
subroutine definition (but for identical order in the parameter list) it works
as expected:

subroutine test_arg_order(key,keylen)
  implicit none
  integer, intent(in)            :: keylen
  character*(keylen), intent(in) :: key
end subroutine test_arg_order

>gfortran -c test.F90
>

i.e. no error in this case.

Both versions of the code still compiled without error on older gfortran 4.8.x
versions (redhat 7).

The same error message was triggered in the case reported for bug #68108, but
to me this seems a different use case.

Reply via email to