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

Daniel C Chen cdchen at ca.ibm.com
Tue Sep 21 19:04:01 UTC 2021



Thanks John and Milan for the quick response. That is exactly what I was
looking for.

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



From:	"Milan Curcic via J3" <j3 at mailman.j3-fortran.org>
To:	"General J3 interest list" <j3 at mailman.j3-fortran.org>
Cc:	"Milan Curcic" <caomaco at gmail.com>
Date:	2021-09-21 01:49 PM
Subject:	[EXTERNAL] Re: [J3] Is it standard conforming to index a
            zero-sized array?
Sent by:	"J3" <j3-bounces at mailman.j3-fortran.org>



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 ‍‍‍‍‍‍
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/18a847e4/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20210921/18a847e4/attachment.gif>


More information about the J3 mailing list