Re: Pointers to derived type objects in COMMON
- From: Tobias Burnus <burnus@xxxxxxxx>
- Date: Sun, 27 Apr 2008 09:00:53 -0700 (PDT)
On Apr 27, 3:48 pm, Walter Spector <w6ws_xthiso...@xxxxxxxxxxxxx>
wrote:
type wws_t ! No SEQUENCE and has default initialization
integer :: x = 1, y = 2, z = 3
end type
type (wws_t), pointer :: my_wwsptr
common /block/ my_wwsptr
As follow up question: What if there is a SEQUENCE attribute? Is this
then valid or not? (The default initializer does not get applied to
the pointer, only to its target. Thus there is no reason why it should
be invalid --- unless C589 does not allow it.)
"C589 (R558) If a common-block-object is of a derived type, it shall be
a sequence type or a type with the BIND attribute and it shall have no
default inititialization."
But what about *pointers* to the objects? If I merely want to place
a pointer to the object in the COMMON block, my reading of §5.5.2
says that it is legal to allow the pointer regardless.
Contrary to you, my reading is that this applies also to a pointer to
a derived type.
However, even if it does not apply (then see my question above), one
can argue that without SEQUENCE it is invalid:
a) "A data pointer shall be storage associated only with data pointers
of the same type and rank." (§5.5.2.3)
b) "Data entities in different scoping units also have the same type
if they are declared with reference to different derived-type
definitions that specify the same type name, all have the SEQUENCE
property or all have the BIND attribute, have no components with
PRIVATE accessibility, and have type parameters and components that
agree in order, name, and attributes." (§4.5.1.3)
c) "A pointer occupies a single unspecified storage unit that is
different from that of any nonpointer object and is different for each
combination of type, type parameters, and rank." (§16.4.3.1, (8))
d) "Named common blocks of the same name shall be of the same size in
all scoping units of a program in which they appear" (§5.5.2.4)
Glue this all together and you see the SEQUENCE is needed. (Unless the
same TYPE is host/use associated in all scoping units where that
COMMON block appears; then we are back at asking whether C589
applies.)
Tobias
.
- Follow-Ups:
- Re: Pointers to derived type objects in COMMON
- From: Walter Spector
- Re: Pointers to derived type objects in COMMON
- References:
- Pointers to derived type objects in COMMON
- From: Walter Spector
- Pointers to derived type objects in COMMON
- Prev by Date: Re: Using external subroutines in OpenMP?
- Next by Date: Re: gfortran produces huge executables
- Previous by thread: Pointers to derived type objects in COMMON
- Next by thread: Re: Pointers to derived type objects in COMMON
- Index(es):
Relevant Pages
|
|