(j3.2006) more on J32031 equivalence of circular types

Andy Vaught andyv
Thu Aug 21 21:55:19 EDT 2008


On Thu, 21 Aug 2008, Bill Long wrote:

> Michael Ingrassia wrote:
> >
> > As for Bill's question (is this only a theoretical concern), I ran the Sun
> > compiler on the sample program and we accept it without errors, which is
> > evidence that we treat A's type and B's type as the same.  Maybe others
> > want to check their compilers.
> >
> >   
> To recall, the program is:
> 
>         MODULE FOO
>         TYPE T
>            SEQUENCE
>            TYPE(T), POINTER :: NEXT => NULL()
>         END TYPE T
>         TYPE(T) :: A
>         END MODULE FOO
> 
>         MODULE BAR
>         TYPE T
>            SEQUENCE
>            TYPE(T), POINTER :: NEXT => NULL()
>         END TYPE T
>         TYPE(T) :: B
>         END MODULE BAR
> 
>         USE FOO, ONLY : A
>         USE BAR, ONLY : B
> 
>         ! Do A and B have the same type ?
>         A = B
>         END
> 
> 
> Here are the results from the compilers I have available:
> 
> Cray: clean compile - same as SUN.
> 
> Pathscale: clean compile as well.
> 
> PGI: Fatal - terminated by signal 11.  [compiler aborted]
> 
> gfortran: Internal error: Segmentation fault (program f951)  [compiler 
> aborted]
> 
> g95: Gave this curious error message:
> 
> In file ./test.f90:7
> 
>         TYPE(T) :: A
>                    1
> Error: Module variable 'a' at (1) with a default initialization must 
> have the SAVE attribute


  To deal with the original equation, if you get rid of the component
initialization, g95 accepts the two types as equal.


>From section 11 of F2003:
---------------------------------

C1107 (R1104) If an object of a type for which component-initialization is
              specified (R444) appears in the specification-part of a
              module and does not have the ALLOCATABLE or POINTER
              attribute, the object shall have the SAVE attribute.

>         MODULE FOO
>         TYPE T
>            SEQUENCE
>            TYPE(T), POINTER :: NEXT => NULL()
>         END TYPE T
>         TYPE(T) :: A
>         END MODULE FOO

  The same constraint appears in F95, section 11.3.  Did I misread it
somehow?

  The message is not quite right, though.  I've replaced "default
initialization" with "component initialization".

    Thanks,
      Andy





More information about the J3 mailing list