Re: Pointers to derived type objects in COMMON



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.
.



Relevant Pages

  • Re: Cohens paper on byte order
    ... > depend on the applicability of the common hex notation. ... bit sequence, there is a bit-order-within-unit issue for ... *any* multibit storage units, not just octet units, and ... fact true of almost all data storage and transmission ...
    (sci.crypt)
  • Re: World Moonie Herald: The challenge to Darwins theory of evolution - 5
    ... Denton presented his critique of neo-Darwinism based on the latest ... all types of cytochrome-c is similar and therefore common. ... amino-acid sequence differs according to organisms. ...
    (talk.origins)
  • Re: Rvalue of struct type
    ... the expression "funTest.a" yields an rvalue of type array of char, ... how can it be converted to pointer type when we can have pointer ... the next sequence point, or modifying it, results in undefined ...
    (comp.lang.c)
  • Re: Cantors definition of set
    ... I would not like to say that they have anything in common. ... of the signs we use to portray numbers, ... arranged in a sequence and not numbers after all? ...
    (sci.logic)
  • Re: Pointers to derived type objects in COMMON
    ... What if there is a SEQUENCE attribute? ... the pointer, only to its target. ... "A data pointer shall be storage associated only with data pointers ... "Data entities in different scoping units also have the same type ...
    (comp.lang.fortran)