https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103662

--- Comment #17 from Mikael Morin <mikael at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #15)
> Now, the question is what is the Fortran unlimited polymorphic semantics, if
> one can store through one type and read through a different type which just
> has the same layout, or if it also has to use the same name etc., or if it
> is even acceptable to store through say a type with a pair of integers and
> read through a type with double precision etc.

I think the pointer assignments in foo are invalid:


10.2.2.3 Data pointer assignment
… If the pointer object is of a type with the BIND attribute or the SEQUENCE
attribute, the dynamic type of the pointer target shall be that type.

 => the dynamic type of tgt shall be respectively s and t

7.3.2.3 CLASS type specifier
… The dynamic type of an associated polymorphic pointer is the dynamic type of
its target.

 => the dynamic type of tgt is that of z
 => the dynamic type of z is that of y
 => the dynamic type of y is that of x, which is sq

7.5.2.4 Determination of derived types
… Data entities 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 attribute or all have the BIND attribute, have no components with
PRIVATE accessibility, and have components that agree in order, name, and
attributes. Otherwise, they are of different derived types.

 => sq and s are different types (different component name)
 => sq and t are different types (different component name, bind(c), sequence)
 => s and t are different types (bind(c), sequence)


So ptr1 and ptr2 should either have type sq, or s and t should be changed to be
"compatible" with sq. And "compatible" is defined in the 7.5.2.4 excerpt above.

Reply via email to