https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92178
Bug ID: 92178 Summary: Segmentation fault after passing allocatable array as intent(out) and its element as value into the same subroutine Product: gcc Version: 9.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: vladimir.fuka at gmail dot com Target Milestone: --- This code crashes at the allocated() call with GCC 7,8,9. I am not completely sure all aliasing rules, but I think it should be fine. implicit none integer, allocatable :: a(:) allocate(a, source=[1]) call assign(a, (a(1))) print *, allocated(a) contains subroutine assign(a, b) integer, allocatable, intent(out) :: a(:) integer, value :: b end subroutine end program based on https://stackoverflow.com/questions/58504284/assignment-of-allocatable-array-with-itself-values/58506248#58506248 > gfortran -fsanitize=address -g -fbacktrace assign.f90 > ./a.out ASAN:DEADLYSIGNAL ================================================================= ==19756==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x000000401354 bp 0x7ffd1a55b460 sp 0x7ffd1a55b0e0 T0) ==19756==The signal is caused by a READ memory access. ==19756==Hint: address points to the zero page. #0 0x401353 in MAIN__ /home/lada/f/testy/stackoverflow/assign.f90:9 #1 0x401631 in main /home/lada/f/testy/stackoverflow/assign.f90:9 #2 0x7fb2b52cef89 in __libc_start_main (/lib64/libc.so.6+0x20f89) #3 0x400c89 in _start (/home/lada/f/testy/stackoverflow/a.out+0x400c89) AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV /home/lada/f/testy/stackoverflow/assign.f90:9 in MAIN__ ==19756==ABORTING