https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100440
--- Comment #13 from David.Smith at lmu dot edu --- Thanks for working on the bug I reported in May. I am hoping you can give me some information that I can pass on to the users of my open-source software who use gfortran to run it. Can you estimate when the fix will appear in an official release of gfortran, and what version number to look for? Thanks, David Smith ________________________________________ From: anlauf at gcc dot gnu.org <gcc-bugzi...@gcc.gnu.org> Sent: Tuesday, May 11, 2021 1:23 PM To: Smith, David Subject: [Bug fortran/100440] allocated() gives True for unallocated variable https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100440 --- Comment #12 from anlauf at gcc dot gnu.org --- A small variation of the testcase in comment#9 suggests that there are actually two underlying issues: lack of initialization and a missing temporary. program p implicit none type fm real, allocatable :: mp(:) integer :: dummy = 42 end type type(fm), allocatable :: a(:), b(:) integer :: n = 1 allocate (a(n)) print *, "main:", n, allocated (a(n)% mp), a(n)% dummy b = mm (a) a = mm (b) a = mm (a) a = mm (a) ! crashes here with -fsanitize=address contains function mm (ma) type(fm), intent(in) :: ma(:) type(fm) :: mm(size(ma)) integer :: i ! type(fm) :: z(size(ma)) ! mm = z ! Explicit initialization of function result do i = 1, size(ma) print *, "in mm:", i, allocated (mm(i)% mp), mm(i)% dummy end do end function mm end program p This gives: main: 1 F 42 in mm: 1 F 0 in mm: 1 F 42 in mm: 1 F 0 in mm: 1 T 0 while with -fsanitize=address,undefined : main: 1 F 42 in mm: 1 F -1094795586 in mm: 1 F 42 in mm: 1 T -1094795586 in mm: 1 T -1094795586 Program received signal SIGSEGV: Segmentation fault - invalid memory reference. Backtrace for this error: #0 0x14987da6f49f in ??? [...] #6 0x409669 in p at /home/anlauf/gcc-bugs/pr100440-red3.f90:14 #7 0x4097d9 in main at /home/anlauf/gcc-bugs/pr100440-red3.f90:14 -- You are receiving this mail because: You reported the bug.