Re: Pointers to derived type objects in COMMON
- From: Walter Spector <w6ws_xthisoutx@xxxxxxxxxxxxx>
- Date: Sun, 27 Apr 2008 11:42:19 -0700
Tobias Burnus wrote:
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.)
It seems to me that default initialization should work, if a derived
type object were used in conjunction with a BLOCK DATA routine.
However I see no verbage allowing it in the Standard. Another wierdness...
In any event, my current concern is with pointers to derived type objects.
"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.
I can read it either way, and compiler developers have implemented
it both ways.
I guess it depends on how far one views the concept of a 'typed pointer'
extending.
[a number of good references deleted]
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.)
In my case, not the minimal code presented upthread, the code obtains
the definition of the derived type via USE association. So any place
where the common block appears (currently that can be counted on one
finger), the same type would be consistently used.
Tobias, I appreciate your interest in this!
W.
.
- Follow-Ups:
- Re: Pointers to derived type objects in COMMON
- From: Richard Maine
- Re: Pointers to derived type objects in COMMON
- References:
- Pointers to derived type objects in COMMON
- From: Walter Spector
- Re: Pointers to derived type objects in COMMON
- From: Tobias Burnus
- Pointers to derived type objects in COMMON
- Prev by Date: Re: Are f.p. manipulation functions only used in initialization?
- Next by Date: Re: Are f.p. manipulation functions only used in initialization?
- Previous by thread: Re: Pointers to derived type objects in COMMON
- Next by thread: Re: Pointers to derived type objects in COMMON
- Index(es):
Relevant Pages
|
|