http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60560
Bug ID: 60560 Summary: Problem allocating character array with assumed length Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: mrestelli at gmail dot com The following code does not compile with gfortran (either 4.7.3 or trunk). My understanding is that the code is legal but gfortran is confused by the fact that: s_tmp takes its length from s s is allocated to size(s_tmp) The point is, the lengths of both s and s_tmp are fixed on entry in the subroutine, and the allocation statement uses size(s_tmp) which has nothing to do with s. (For what is worth, the code compiles with ifort). module mstr implicit none contains subroutine sub(s) character(len=*), allocatable, intent(out) :: s(:) character(len=len(s)), allocatable :: s_tmp(:) ! does not work !character(len=10), allocatable :: s_tmp(:) ! this works allocate(s_tmp(5)) allocate(s(size(s_tmp))) end subroutine sub end module mstr gfortran -c mstr.f90 mstr.f90:11.12: allocate(s(size(s_tmp))) 1 Error: 's' must not appear in the array specification at (1) in the same ALLOCATE statement where it is itself allocated