Re: association with zero-length array?



On Aug 15, 1:05 pm, "James Van Buskirk" <not_va...@xxxxxxxxxxx> wrote:


Could you provide us with an example or two of such confusing results?

Off the top of my head, no. The text I cited was added to the
language in F95 due to F90 Interpretation 27, which I append below.
The idea seems to be that if one of the arrays is zero sized, there
are no elements which are "the same storage units in array element
order". An array with no elements has no allocated storage, so how
can one ask if a pointer shares the same storage?

Here's the text of the interp:

NUMBER: 000027
TITLE: Requirements for pointer and target association
KEYWORDS: POINTER attribute, TARGET attribute, pointer association
DEFECT TYPE: Erratum
STATUS: WG5 approved; ready for SC22

QUESTION: If PTR has the POINTER attribute and TGT has the TARGET or
POINTER attribute, under which of the following other conditions are
PTR
and TGT considered to be pointer associated, i.e., under which of the
following conditions does ASSOCIATED(PTR, TGT) return a value
of .TRUE.:

a) PTR and TGT have different types?
b) PTR and TGT have different type parameters?
c) PTR and TGT have different ranks?
d) PTR and TGT have different sizes?
e) PTR and TGT have different shapes?
f) PTR and TGT have different bounds?
g) PTR and TGT refer to the same set of array elements/storage units,
but
not in the same array element order?
h) PTR and TGT have array elements/storage units whose range of memory
addresses
overlap, but they have no identical array elements/storage units?
i) PTR and TGT have at least one but not all identical array
elements/storage units and all the identical elements have the same
subscript order value in both PTR and TGT?
j) PTR and TGT have at least one but not all identical array
elements/storage units but not all the identical elements have the
same sub
script order value in both PTR and TGT?

ANSWER: The conditions d), e), g), h), i) and j) are sufficient for
ASSOCIATED (PTR, TGT) to return a value of .FALSE.. The conditions
a), b), c)
and d) are such that if any are true, ASSOCIATED (PTR, TGT) is an
invalid
reference. In determining whether a pointer and a target are
associated, the
bounds are relevant only for determining which elements are
referenced. The
extents of each dimension of PTR and TGT must be the same, thus their
shapes
must match which is covered by condition (e). If TGT is zero sized,
ASSOCIATED
(PTR, TGT) returns .FALSE..

Discussion: It is the intent of the standard that the two argument
form of
the ASSOCIATED intrinsic function returns true only if the association
of
POINTER and TARGET is as if the pointer assignment statement

POINTER => TARGET

was the last statement executed prior to the execution of the
statement
invoking the ASSOCIATED function. This is not clear in the
definition of
the ASSOCIATED intrinsic or elsewhere in the standard. Clarifying
edits
are provided.

EDITS:
1. In section 13.13.13 [198:31] in the description of the TARGET dummy
argument
add
", and have the same type, type parameters, and rank as
POINTER"
following
"must be a pointer or target"

2. In section 13.13.13 replace Case (ii) with [198:37-38]
"Case (ii): If TARGET is present and is a scalar target, the
result is true if TARGET is not a zero-sized
storage
sequence and the target associated with POINTER
occupies
the same storage units as TARGET. Otherwise the
result is
false. If POINTER is disassociated, the result
is false."

3. In section 13.13.13 replace Case (iii) [199:1-3] with
"Case (iii): If TARGET is present and is an array target, the
result is true if the target associated with
POINTER and
TARGET have the same shape, are neither of size
zero nor
arrays whose elements are zero-sized storage
sequences,
and occupy the same storage units in array
element order.
Otherwise the result is false. If POINTER is
disassociated, the result is false.

Case (iv): If TARGET is present and is a scalar pointer,
the
result is true if the target associated with
POINTER and
the target associated with TARGET are not zero-
sized
storage sequences and they occupy the same
storage units
Otherwise the result is false. If either
POINTER or
TARGET is disassociated, the result is false.

Case (v): If TARGET is present and is an array pointer,
the result
is true if the target associated with POINTER
and the
target associated with TARGET have the same
shape, are
neither of size zero nor arrays whose elements
are
zero-sized storage sequences, and occupy the
same storage
units in array element order. Otherwise the
result is
false. If either POINTER or TARGET is
disassociated, the
result is false."

SUBMITTED BY: Jon Steidel, 120-JLS-4 (120.022)
HISTORY: 120-LJM-3A (120.081A)
m121 Original response proposed
92-061 (121-ADT-9) p9 & X3J3/92-061 Questioned
response
(121-ADT-13) item 27
92-093A m121 Approved
92-329 (jw note)
m123 Approval rescinded at m123 (uc)
93-099r1 m124 Revised response adopted (15-2)
93-111 m125 ballot failed, returned to subgroup
93-135r m125 Based on comments returned with the X3J3 letter
ballot following m124, the revised response
was
prepared and adopted 15-3.
93-255r1 m127 ballot failed 17-7
94-289 m130 revised answer, approved u.c.
94-306 m131 X3J3 ballot failed 16-3
95-281 m135 revised response, added edits, WG5 approved
96- m136 X3J3 ballot approved 15-1, retains WG5 approval
-------------------------------------------------------------------------------

Steve

.



Relevant Pages

  • Re: association of pointers
    ... INTEGER, TARGET:: beast = 666 ... PRINT "",' After ptr = beast, ptr is',ptr ... target are distinct entities; their association is temporary. ... anonymous target and then to associate the pointer with that target. ...
    (comp.lang.fortran)
  • Re: TARGET and INTENT(IN)
    ... you can use a pointer to point at something and then modify it through the pointer. ... A pointer is very much like a dummy argument. ... With this meaning of "TARGET" for INTENTdummys I don't see the point - the compiler still doesn't do anything different than for INTENTdummys without TARGET. ... I've been known to have wrapper routines that try to make life simpler for both the routines that calls them and the lower-level routines that they call. ...
    (comp.lang.fortran)
  • Re: Pointers in structure constructors
    ... the actual argument will be an appropriate target, ... It is the compiler's tolerance for inappropriate use of my provided "structure constructor" that is bothering me. ... dummy argument, the actual argument may not be a null pointer. ...
    (comp.lang.fortran)
  • Re: Rules for valid pointer deallocation
    ... forrtl: severe: A pointer passed to DEALLOCATE points to an array ... the allocated array is 10 and the extent of the target ... dummy array is also 10, because n is 10 in this ...
    (comp.lang.fortran)
  • Recursive Algorithm again
    ... the target is to traverse a field of 3 x 3 where it is started at ... There is indicated the pointer 3. ... RECURSIVE SUBROUTINE next_node ... ENDDO ...
    (comp.lang.fortran)