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

            Bug ID: 84778
           Summary: Issue with character arguments of specified length
                    (does not compile)
           Product: gcc
           Version: 7.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: david.applegate at woodplc dot com
  Target Milestone: ---

Pass a character "a"  into a subroutine with an additional argument integer "b"
which specifies its length.  This does not compile if integer "b" is declared
after character "a" in the subroutine. See below

program test

  implicit none
  integer, parameter :: b = 5
  character(len=b) :: a

  a = "hello"

  write(*,*)a//" from main program"

  call testsub(a,b)

contains

  subroutine testsub(a,b)

    ! integer, intent(in) :: b   ! if we put declaration of b here instead it
compiles ok
    character(len=b), intent(in) :: a
    integer, intent(in) :: b 

    write(*,*)a//" from testsub"

  end subroutine testsub
end program test

Reply via email to