http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45170

--- Comment #27 from Steve Kargl <sgk at troutmask dot apl.washington.edu> 
2011-08-29 16:22:16 UTC ---
On Mon, Aug 29, 2011 at 06:47:41AM +0000, burnus at gcc dot gnu.org wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45170
> 
> --- Comment #26 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-08-29 
> 06:47:41 UTC ---
> (In reply to comment #24)
> > Your code in comment #14 is (I believe) invalid, and gfortran
> > is issuing the correct error message.
> 
> I get:
>   Error: Variable 'length' cannot appear in the expression at (1)
> 
> However, I believe that 
>   allocate(character(len=length)::string)
> is valid.
> 
> One has (F2008):
>   R626 allocate-stmt is ALLOCATE ( [ type-spec :: ] allocation-list
>                                    [, alloc-opt-list ] )
> with
>   R402 type-spec  is  intrinsic-type-spec  or  derived-type-spec
> with 
>   R404 intrinsic-type-spec  is  [...]
>                             or  CHARACTER [ char-selector ]
> with
>   R420 char-selector  is  length-selector [or ...]
> with
>   R421 length-selector is ( [ LEN = ] type-param-value )  [or ...]
> 

>From F2003:

C402 (R402) The type-param-value for a kind type parameter shall be
an initialization expression.

7.1.7

An initialization expression is an expression with limitations that
make it suitable for use as a kind type parameter, initializer, or
named constant.  It is an expression in which each operation is
intrinsic, and each primary is

      (1)   A constant or subobject of a constant,


character(:),allocatable::string
integer::length
length=5
allocate(character(len=length)::string)

length is not a constant.

Reply via email to