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

--- Comment #8 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Wed, Nov 21, 2018 at 08:49:55AM +0000, tkoenig at gcc dot gnu.org wrote:
> 
> --- Comment #6 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
> The type has SEQUENCE, so I think this should actually work... or did I miss
> something here?
> 

Remove the INCLUDE from the problem, and consider

program foo
   type aaa
      integer i
   end type aaa
   type(aaa) a
   call bar(a)
   print *, a%i
end program foo

subroutine foo(a)
   type aaa
      character(4) i
   end type aaa
   type(aaa) a
   a%i = 'abcd'
end subroutine foo

Put each unit in its own file, compile each separately, and link.
type aaa is clearly not the same both unit.  Do you expect to link 
and execute the program?  You can now change character(4) to integer.
How is the compiler to know that the types are the same as the types
are in different namespaces.  Sure, it may compile, link, and execute
but I think that is undefined behavior.  I also think SEQUENCE is a
red herring here, as its only purpose is to restrict a compiler from
re-ordering components in a type with multiple components. 

The fix for the person in fortran@ is trivially stupid.  Use a module.

Reply via email to