In Fortran 2018’s definition of derived type component specifications we have this constraint:
C750 (R740) Each bound in the explicit-shape-spec shall be a specification expression in which there are no references to specification functions or the intrinsic functions ALLOCATED, ASSOCIATED, EXTENDS_TYPE_OF, PRESENT, or SAME_TYPE_AS, every specification inquiry reference is a constant expression, and the value does not depend on the value of a variable.
I’m curious what you all might think the phrase “does not depend on the value of a variable” means in the context of this example.
module m type :: t(len) integer, len :: len integer :: a(len) end type contains subroutine subr(j) integer, intent(in) :: j type(t(j)) :: x end subroutine end module
The declaration of the component
a in the PDT
t depends on the value of the length type parameter
len, and at the declaration of the variable
x, the value of
len does depend on the incoming value of the dummy argument
j. So does this example violate C750, because it causes a bound to be transitively and eventually dependent on the value of a variable?
(Most Fortran compilers accept this usage.)
There’s a similar question that can be raised about C754.