[J3] Question on component definition statement in a derived type involving a length-type parameter along with (apparently) constant expression

Van Snyder Van.Snyder at jpl.nasa.gov
Tue Aug 7 13:01:44 EDT 2018


On Tue, 2018-08-07 at 12:20 -0400, Steve Lionel via J3 wrote:
> On 8/7/2018 12:06 PM, Vipul Parekh via J3 wrote:
> > Is the following code standard-conforming?
> >
> > --- begin code ---
> >     integer, parameter :: L(*) = [ 1, 2, 3 ]
> >     type :: t(N)
> >        integer, len :: N
> >        integer :: x( L(N) )       !<-- processors balk at L(N) in this
> > component definition stmt
> >     end type
> > end
> > --- end code ---
> >
> > In the above code, L(N) appears to me a constant expression and which
> > should make the component definition conform to the standard.  But the
> > 2 compilers I tried throw errors.
> 
> Referencing 10-007: 4.2p5 says, "A length type parameter may be used in 
> specification expressions within the derived-type definition for the 
> type, but it shall not be used in constant expressions."
> 
> So, no, this is not standard conforming.

But the specification for a bound in a derived-type definition is not
required to be a constant expression.  For example, in note 7.22 (in
18-007) a length parameter is used for an array bound.

> Steve
> 




More information about the J3 mailing list