Silverfrost Forums

Welcome to our forums

sequence derived types needed

23 Dec 2012 11:27 #11343

In the following code, the compiler should generate an error because the derived type foo_t is not a sequence type. However, it doesn't.

Although there is an explicit interface for subroutine init, the type foo_t it requires as an argument is not being USEd by the program anon, which is actually creating its own, different type.

The correct error is generated by FTN95 if init is just made an external subroutine without an explicit interface.

module mmm
contains
   subroutine init(foo)
      type foo_t
         real :: a
         real :: b
      end type foo_t
      type (foo_t), intent(out) :: foo
      foo%a = 1.0; foo%b = 2.0
   end subroutine init
end module mmm

program anon
   use mmm
   type foo_t
      real :: a
      real :: b
   end type foo_t
   type (foo_t) :: foo
   call init(foo)
   print *, foo%a, foo%b
end program anon

The code can be made 'correct' by changing foo_t in each place to:

   type foo_t
      sequence
      real :: a
      real :: b
   end type foo_t

P.S. Most other compilers I have also fail to detect this and similar cases where sequence is needed. :roll:

24 Dec 2012 9:11 #11346

Thanks for this. I have logged it for attention.

Please login to reply.