Initialization bug


The following program shows an initialization bug which occurs in the current version
of the compiler.

module lib
  implicit none

  type :: A
     integer :: iA = -1
  end type A

  type (A), dimension (0:2), save :: Abox


  subroutine init_A ()

    Abox(1)%iA = 1  

  end subroutine init_A

end module lib

program test
  use lib
  implicit none

  call init_A ()

  print *, Abox(0)%iA
!! ERROR Should be -1 instead of 0

end program test

Furthermore, if we omit save attribute in the definition of Abox and break the F95 standard in this way - the program compiles without error even though the option -Mstandard is used.


Hi Jamie,

It looks like a bug in the 6.1 compiler since it works as expected with 6.0. I’ve added a technical problem report (TPR #3840) and hopefully we can get this issue resolved quickly.

Thanks for the report,