[J3] Is it standard conforming to index a zero-sized array?
John Reid
John.Reid at stfc.ac.uk
Tue Sep 21 17:49:14 UTC 2021
Daniel C Chen via J3 wrote:
>
> Is the following code legal?
>
> integer, allocatable :: arr(:)
> allocate(arr(0))
> arr(5) = 1 !! Is this line legal?
> end
>
> I understand a zero-sized array is always defined and it can be used
> as LHS of an assignment. But is it legal to indexing it?
> I seems can't find any specific rule about it in the standard.
>
[128:6] in 18-007r1 says "The value of a subscript in an array element
shall be within the bounds for its dimension."
Cheers,
John.
>
> Thanks,
>
> Daniel Chen
>
> XL Fortran Development, Fortran Standard Representative
> IBM Toronto Software Lab
> Phone: 905-413-3056
> Tie: 969-3056
> Email: cdchen at ca.ibm.com
>
More information about the J3
mailing list