https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84523
--- Comment #8 from Dominique d'Humieres <dominiq at lps dot ens.fr> --- For the record: > Caused by revision r257065. > Quite why this testcase worked before revision r257065 I cannot for the life > of me understand. Actually I think this was exposed by r257065 but caused by r251949. The following variant is OK with r251946 program gfcbug148 implicit none type t_spot real, allocatable :: vm(:,:,:) end type t_spot type t_rowcol integer :: nh type(t_spot), pointer :: spots(:) =>NULL() end type t_rowcol type(t_rowcol) :: col call construct (col, 80) call destruct (col) print *, "OK" !======================================================================== contains !======================================================================== subroutine construct (rc, nh) type(t_rowcol) ,intent(out) :: rc ! row or column to set integer ,intent(in) :: nh ! number of spots in a row rc% nh = nh allocate (rc% spots (nh)) end subroutine construct !------------------------------------------------------------------------ subroutine destruct (rc) type(t_rowcol) ,intent(inout) :: rc ! row or column to free integer :: k if (associated (rc% spots)) then print *, "### destruct: size(rc% spots)=", size(rc% spots) if (size(rc% spots) > 1) then print *, "### destruct: allocated (vm) =", allocated(rc%spots(1)%vm) end if print *, size(rc% spots) do k=1, size(rc% spots) print *, k, allocated (rc% spots(k)% vm) end do print *, "before deallocate" endif nullify (rc% spots) end subroutine destruct end program gfcbug148 but gives with r251980 ### destruct: size(rc% spots)= 80 ### destruct: allocated (vm) = F 80 1 F Program received signal SIGSEGV: Segmentation fault - invalid memory reference. when compiled with -fsanitize=undefined.