[J3] Question on component definition statement in a derived type involving a length-type parameter along with (apparently) constant expression
Vipul Parekh
parekhvs at gmail.com
Tue Aug 7 12:06:48 EDT 2018
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.
For some background on the query, you can consider the current
standard document (10-007r1) for component definition statement in a
derived type that has in section 4.5.2 Derived-type definition and
under 4.5.4.1 Component definition statement
8 R437 component-attr-spec is access-spec
..
12 or DIMENSION ( component-array-spec )
..
14 R438 component-decl is component-name [ ( component-array-spec ) ]
..
17 R439 component-array-spec is explicit-shape-spec-list
18 or deferred-shape-spec-list
with
32 C446 (R439) Each bound in the explicit-shape-spec shall be a
specification expression in which there are
33 no references to specification functions or the intrinsic functions
ALLOCATED, ASSOCIATED, EX-
34 TENDS TYPE OF, PRESENT, or SAME TYPE AS, every specification
inquiry reference is a constant
35 expression, and the value does not depend on the value of a variable.
and
NOTE 4.25
Because a type parameter is not an object, a type-param-value or a
bound in an explicit-shape-spec may contain a type-param-name.
Thanks much,
Vipul Parekh
More information about the J3
mailing list