This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/45170] [F2003] allocatable character lengths
- From: "sgk at troutmask dot apl.washington.edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 29 Aug 2011 16:22:16 +0000
- Subject: [Bug fortran/45170] [F2003] allocatable character lengths
- Auto-submitted: auto-generated
- References: <bug-45170-4@http.gcc.gnu.org/bugzilla/>
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.