[J3] Is it standard conforming to index a zero-sized array?

Milan Curcic caomaco at gmail.com
Tue Sep 21 17:49:05 UTC 2021


Hi Daniel,

I think this is covered by 9.5.3.1:

> 2 The value of a subscript in an array element shall be within the bounds
for its dimension.

Milan

On Tue, Sep 21, 2021 at 1:32 PM Daniel C Chen via J3 <
j3 at mailman.j3-fortran.org> 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.
>
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20210921/97cea9f7/attachment.htm>


More information about the J3 mailing list