https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100440
anlauf at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2021-05-08 Ever confirmed|0 |1 Keywords| |wrong-code --- Comment #9 from anlauf at gcc dot gnu.org --- (In reply to Steve Kargl from comment #7) > There is no default initialization in the code below. default > initialization is > > type foo > integer :: i = 1 ! <-- Default initialization > end tyep foo The F2018 standard says: 7.5.4.6 Default initialization for components [...] Allocatable components are always initialized to unallocated. Anyway, the following extension shows that default initialization does not work: program p implicit none type fm real, allocatable :: mp(:) integer :: dummy = 42 end type type(fm), allocatable :: a(:,:) integer :: n = 1 allocate (a(n,n)) a = mm (a, a) a = mm (a, a) ! crashes here with -fsanitize=address contains function mm (ma, mb) type(fm) :: ma(:,:), mb(:,:) type(fm), dimension(size(ma,dim=1),size(mb,dim=2)) :: mm integer :: i, j ! type(fm), dimension(size(ma,dim=1),size(mb,dim=2)) :: z ! mm = z ! Explicit initialization of function result do i = 1, size(ma,dim=1) do j = 1, size(mb,dim=2) print *, i, j, allocated (mm(i,j)% mp), mm(i,j)% dummy end do end do end function mm end program p Which gives: 1 1 F 0 1 1 T 0 and with MALLOC_PERTURB_=2 : 1 1 T -33686019 1 1 T -33686019 Uncommenting the indicated lines in function mm procduces: 1 1 F 42 1 1 F 42 and crashes with MALLOC_PERTURB_=2 Not good.