The following program prints
- "2 42" with gfortran -fno-automatic
- "2 2" with NAG f95 -save and ifort -save

Expected: The SAVE is also implied for derived types with default initializer.

The problem is really the initializer as the dump shows:

  static struct t myt = {.i=42};   <<<<<<< OK since SAVE
  {
    struct t t.1;
    t.1.i = 42;         <<<<<< OK if not SAVE
    myt = t.1;
  }


subroutine foo(n)
  integer :: n
  type t
    integer :: i = 42
  end type t
  type(t) :: myt
  if(n==1) myt%i = 2
  print *, myt%i
end subroutine foo

call foo(1)
call foo(2)
end


-- 
           Summary: -fno-automatic does not work for derived types with
                    default initalizer
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37835

Reply via email to