(j3.2006) A question on pointer association context of a POINTER subobject of a dummy argument with POINTER as well as INTENT(IN) attribute

Van Snyder van.snyder
Thu Oct 12 01:50:18 EDT 2017


On Thu, 2017-10-12 at 05:27 +0000, Bill Long wrote:
> I was careless and just looked at the definition of subobject (in the
> terms list) which says a ?subobject? is
> 
> "	? portion of data object that can be referenced, and if it is a
> variable defined, independently of any other portion?

The terse definitions in clause 3, that are usually necessarily
incomplete, ought to have references to complete descriptions.  Many do
already.

> 
> Cheers,
> Bill
> 
> 
> 
> > On Oct 11, 2017, at 10:45 PM, Malcolm Cohen <malcolm at NAG-J.CO.JP>
> wrote:
> > 
> > No it does not say that.  O%I is ***NOT*** a subobject of O.  This
> is FUNDAMENTAL.
> > 
> > Here is what the standard says:
> >  " A data-ref with more than one part-ref is a subobject of its base
> object if none of the part-names, except for possibly the rightmost,
> is a pointer."
> > 
> > In the case of O%I, the part-ref "O" is a pointer, and is not the
> rightmost part-ref.  Therefore O%I is not a subobject of O.
> > 
> > Anyway, if you look at the paper I submitted several hours ago to
> clarify the INTENT wording, you will see that it indeed clarifies this
> sentence for those who do not remember (or think to check) the rules
> for subobjects.
> > 
> > Cheers,
> > -- 
> > ..............Malcolm Cohen, NAG Oxford/Tokyo.
> > 
> > -----Original Message-----
> > From: Fortran 90 List [mailto:COMP-FORTRAN-90 at JISCMAIL.AC.UK] On
> Behalf Of Bill Long
> > Sent: Thursday, October 12, 2017 11:56 AM
> > To: COMP-FORTRAN-90 at JISCMAIL.AC.UK
> > Subject: Re: [COMP-FORTRAN-90] A question on pointer association
> context of a POINTER subobject of a dummy argument with POINTER as
> well as INTENT(IN) attribute
> > 
> > This part of the INTENT subclause might be confusing, though:
> > 
> > "If an object has an INTENT attribute, then all of its subobjects
> have the same INTENT attribute.?
> > 
> > This seems to say that the component pointer has the INTENT(IN)
> attribute. 
> > 
> > Cheers,
> > Bill
> > 
> > 
> > 
> >> On Oct 11, 2017, at 7:28 PM, Malcolm Cohen <malcolm at NAG-J.CO.JP>
> wrote:
> >> 
> >> Yes the code is standard-conforming.
> >> 
> >> Steve Lionel writes:
> >>> It is not. Note 5.16 even gives an explicit example of this:
> >> 
> >> Steve has missed the fact that the dummy argument is itself a
> pointer, so INTENT(IN) applies to the pointer dummy, not to the
> pointer component of its target.
> >> 
> >>> NOTE 5.16
> >>> If a dummy argument is a derived-type object with a pointer
> component, then the pointer as a pointer is a subobject of the dummy
> >argument, but the target of the pointer is not.
> >> 
> >> The example in 5.16 does not actually show the declaration, but it
> is clear from the description that it is an ordinary INTENT(IN) dummy
> argument, not an INTENT(IN) POINTER.  That is, when it says
> >>     "For example, if X is a dummy argument of derived type with an
> integer pointer component P, and X is INTENT (IN),"
> >> It means
> >>    TYPE(T),INTENT(IN) :: X
> >> Not
> >>    TYPE(T),INTENT(IN),POINTER :: X
> >> 
> >> The NOTE could be better worded, but at the end of the NOTE it is
> stated clearly:
> >> 
> >>     "Similarly, the INTENT restrictions on pointer dummy arguments
> apply only to the association of the dummy argument; they do not
> restrict the operations allowed on its target."
> >> 
> >> I repeat, INTENT(IN) does "not restrict the operations allowed on
> its target", and "o%i => null()" is an operation on the target of the
> pointer "o", therefore it is not affected by INTENT(IN).
> >> 
> >> I think I will propose a couple of wording changes (judicious
> insertion of "nonpointer" in a couple of places) to make this harder
> to misunderstand.
> >> 
> >> Cheers,
> >> -- 
> >> ..............Malcolm Cohen, NAG Oxford/Tokyo.
> >> 
> >> -----Original Message-----
> >> From: Fortran 90 List [mailto:COMP-FORTRAN-90 at JISCMAIL.AC.UK] On
> Behalf Of Steve Lionel
> >> Sent: Thursday, October 12, 2017 4:06 AM
> >> To: COMP-FORTRAN-90 at JISCMAIL.AC.UK
> >> Subject: Re: [COMP-FORTRAN-90] A question on pointer association
> context of a POINTER subobject of a dummy argument with POINTER as
> well as INTENT(IN) attribute
> >> 
> >> On 10/11/2017 10:40 AM, Vipul Parekh wrote:
> >>> Is the following simple code standard-conforming?
> >>> 
> >>> module m
> >>> 
> >>>   type :: t
> >>>      integer, pointer :: i
> >>>   end type
> >>> 
> >>> contains
> >>> 
> >>>   subroutine sub( o )
> >>>      type(t), pointer, intent(in) :: o
> >>>      !o => null()     !<---  A
> >>>      o%i => null()  !<---  B
> >>>   end subroutine
> >>> 
> >>> end module
> >>> 
> >> It is not. Note 5.16 even gives an explicit example of this:
> >> 
> >> NOTE 5.16
> >> If a dummy argument is a derived-type object with a pointer
> component, then the pointer as a pointer is a subobject of the dummy
> argument, but the target of the pointer is not. 
> >> Therefore, the restrictions on
> >> subobjects of the dummy argument apply to the pointer in contexts
> where it is used as a pointer, but not in contexts where it is
> dereferenced to indicate its target. For example, if X is a dummy
> argument of derived type with an integer pointer component P, and X is
> INTENT (IN), then the statement X%P => NEW_TARGET is prohibited, ...
> >> 
> >> Steve
> > 
> > Bill Long
> longb at cray.com
> > Principal Engineer, Fortran Technical Support &   voice:
> 651-605-9024
> > Bioinformatics Software Development                      fax:
> 651-605-9143
> > Cray Inc./ 2131 Lindau Lane/  Suite 1000/  Bloomington, MN  55425
> 
> Bill Long
> longb at cray.com
> Principal Engineer, Fortran Technical Support &   voice:  651-605-9024
> Bioinformatics Software Development                      fax:
> 651-605-9143
> Cray Inc./ 2131 Lindau Lane/  Suite 1000/  Bloomington, MN  55425
> 
> 





More information about the J3 mailing list