Given:
type :: my_type
real, dimension(:), pointer :: x => null()
end type my_type
contains
subroutine legal_sub (a)
type(my_type), intent(in) :: a
Lionel, Steve said:
> Are you arguing that a%x is not a subobject of a?
I'll argue that it's not a subobject.
Or rather, that the F95 standard is unclear and that it ought not to be
considered a subobject.
In F95, the standard is unclear because there are two terms "subobject";
one a BNF term (section 6, page 73) the other a normal textual term (2.4.3.1,
page 16). IMO the description in 2.4.3.1 implies that subobjectness (the
textual term) does not flow through pointers, though the BNF definition of
"<subobject>" clearly does flow through pointers.
If one takes the view that the BNF "<subobject>" is meant to mean the same
as the textual "subobject", then A%X would always be a subobject of A.
However, even with that view, it would still be allowable to do
REAL,POINTER :: P
p => a%x
p = 42
even if
a%x = 42
is not valid.
This inconsistency does not make a lot of sense, lending credence to the
view that "subobject" is simply poorly specified in the F95 standard.
BTW, the F2002 draft standard has clarified the situation; in the case in
question, A%X is only a subobject of A in pointer context. In other
contexts, A%X refers to the target of the pointer which is not a part of A
itself. (Of course, this is only a draft and may change...)
The resolution of interp81 to F95 (on a different but related issue) also
supports the "it ought not to be considered a subobject" theory.
Cheers,
--
...........................Malcolm Cohen, NAG Ltd., Oxford, U.K.
([log in to unmask])
|