The following segfaults on the second call to mah because the allocatable components are automatically deallocated. I have yet to check the F2003 standard but this logically makes no sense. It comes about because t.data is NULLED on entry to mah
program boh ! call mah (0) call mah (1) call mah (2) ! end program boh ! subroutine mah (i) ! integer, intent(in) :: i ! type mix_type real(8), allocatable :: a(:) complex(8), allocatable :: b(:) end type mix_type type(mix_type), allocatable, save :: t(:) integer :: j, n=1024 ! if (i==0) then allocate (t(1)) allocate (t(1)%a(n)) allocate (t(1)%b(n)) do j=1,n t(1)%a(j) = j t(1)%b(j) = n-j end do end if c = sum( t(1)%a(:) ) + sum( t(1)%b(:) ) print *, 'c=',c if ( i==2) then deallocate (t(1)%b) deallocate (t(1)%a) deallocate (t) end if end subroutine mah Posted to the list by F-X COudert http://gcc.gnu.org/ml/fortran/2008-01/msg00044.html -- Summary: SAVEd derived type with allocatable components causes ICE Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pault at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34681