http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51652
Tobias Burnus <burnus at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |accepts-invalid, | |diagnostic, wrong-code CC| |burnus at gcc dot gnu.org Summary|[F03] ICE with allocatable |[F03] ICE with allocatable |scalars |scalarstype parameter --- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-12-22 08:40:10 UTC --- (In reply to comment #0) > type keyword > ! character(60), allocatable :: c(:) ! works but should it? > ! character(80), allocatable :: c(:) ! works > character(:), allocatable :: c(:) > end type keyword Unfortunately, deferred-length type parameters (i.e. allocatable string lengths) are not yet supported for components of derived types. The current version does not crash (ICE, internal compiler error) but prints an error: character(:), allocatable :: c(:) 1 Error: Deferred-length character component 'c' at (1) is not yet supported As this is already tracked in PR 51550, PR 47545, PR 49050, PR 51075 - and PR 45170, I ignore the issue in this PR and concentrate on your second issue. * * * Regarding the allocation: character(60), allocatable :: c(:) allocate(character(80) :: c(10)) That's invalid; currently, the value in the allocate statement is ignored by gfortran. The standard requires that this is diagnosed: "If type-spec appears and the value of a type parameter it specifies differs from the value of the corresponding nondeferred type parameter specified in the declaration of any allocate-object, an error condition occurs. If the value of a nondeferred length type parameter of an allocate-object differs from the value of the corresponding type parameter of source-expr, an error condition occurs." Note that this cannot always diagnosed at compile time, given that also the following is valid: subroutine sub(n) integer :: n character(len=n), allocatable :: str(:) allocate(character(n) :: str(1)) print *, len(str), size(str) end call sub(4) call sub(5) end