[J3] ALLOCATE with source-expr determining the array bound & resulting lower bound
Tobias Burnus
burnus at net-b.de
Wed Dec 1 08:59:31 UTC 2021
On 01.12.21 08:57, Bader, Reinhold wrote:
>> Von: Tobias Burnus
>>
>> However, for allocate with source-expr I still wonder about the bounds.
>>
>> And I still think it would be useful to explicitly state that the lower bounds
>> comes from applying LBOUND to the source-expr. (Matching what is done at
>> several other places in the standard: intrinsic assignments to allocatables,
>> pointer association, 'associate', 'select rank'.)
> These semantics apply for all array expressions, so an explicit statement would need to be added
> to 10.1.1. Given that we've lived with this for decades I'm not sure such an addition is necessary.
True - but in most cases, the lower bound of an expression is not needed.
It is only required when referencing LBOUND and for whole arrays, where
it matters for array-element / array-section (and LBOUND).
But all those seem to be covered – except for ALLOCATE with source-expr,
which just has "the bounds of source-expr determine the bounds of the array.":
All the other have an explicit lower bound:
Either in declaration
* explicit-shape arrays via explicit-shape-spec
* assumed-shape arrays via assumed-shape-spec
* assumed-size array via assumed-implied-spec
(and the fallback 'otherwise that lower bound is 1')
or for
* ALLOCATE with allocate-shape-spec
* (Re)allocation on intrinsic assignment:
"it is then allocated with ... the shape of expr with each lower bound
equal to the corresponding element of LBOUND (expr) if expr is an array."
* Data-pointer assignment:
"If bounds-spec-list appears, it specifies the lower bounds; otherwise,
the lower bound of each dimension is the result of the intrinsic function
LBOUND (16.9.109) applied to the corresponding dimension of the pointer target."
* associate names:
"Within an ASSOCIATE, CHANGE TEAM, or SELECT TYPE construct, each associating
entity has the same rank as its associated selector. The lower bound of each
dimension is the result of the intrinsic function LBOUND (16.9.109) applied
to the corresponding dimension of selector."
* SELECT RANK associate name
"the lower bound of each dimension is the result of the intrinsic function
LBOUND (16.9.109) applied to the corresponding dimension of the selector,"
Thus, while it could be added to 10.1.1, it seems to make more sense to
add it to the ALLOCATE with source-expr for items without
allocate-shape-spec.
Tobias
More information about the J3
mailing list