Extracted a reproducer that is only a few lines from a large module, but do not see what is going on. Even moving the order of the subroutines, declaring i in the subroutine instead of the top of the module, or just about any change eliminates the problem, and it does not occur on my machine with version 10 of gfortran. module m_module integer :: i contains subroutine subaaa() do i=1,2 call subbbb() enddo end subroutine subaaa subroutine subbbb() call random_number(r) end subroutine subbbb subroutine subccc() call subaaa() end subroutine subccc end module m_module gfortran -c M_module.f90 951: internal compiler error: Segmentation fault 0x14f925f1108f ??? /build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0 0x14f925ef2082 __libc_start_main ../csu/libc-start.c:308 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <file:///usr/share/doc/gcc-11/README.Bugs> for instructions. gfortran --version GNU Fortran (Ubuntu 11.1.0-1ubuntu1~20.04) 11.1.0 Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Linux mercury 5.4.0-132-generic #148-Ubuntu SMP Mon Oct 17 16:02:06 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
I can't reproduce on the top of the GCC 11 branch, can you please try updating the compiler to 11.3.0 at least? For me it reproduces with GCC 11.1 and 11.2 but not with 11.3 which means it appears fixed. Proper backtrace: f951: internal compiler error: Segmentation fault 0xc27c3f crash_signal /space/rguenther/src/gcc-11-branch/gcc/toplev.c:327 0x745c60 gfc_sym_get_dummy_args(gfc_symbol*) /space/rguenther/src/gcc-11-branch/gcc/fortran/symbol.c:5256 0x7e25f9 doloop_contained_procedure_code /space/rguenther/src/gcc-11-branch/gcc/fortran/frontend-passes.c:2483 0x7e96e9 gfc_code_walker(gfc_code**, int (*)(gfc_code**, int*, void*), int (*)(gfc_expr**, int*, void*), void*) /space/rguenther/src/gcc-11-branch/gcc/fortran/frontend-passes.c:5333 0x7eb0b8 doloop_code /space/rguenther/src/gcc-11-branch/gcc/fortran/frontend-passes.c:2627 0x7e96e9 gfc_code_walker(gfc_code**, int (*)(gfc_code**, int*, void*), int (*)(gfc_expr**, int*, void*), void*) /space/rguenther/src/gcc-11-branch/gcc/fortran/frontend-passes.c:5333 0x7e97fe gfc_code_walker(gfc_code**, int (*)(gfc_code**, int*, void*), int (*)(gfc_expr**, int*, void*), void*) /space/rguenther/src/gcc-11-branch/gcc/fortran/frontend-passes.c:5657 0x7ea92b doloop_warn /space/rguenther/src/gcc-11-branch/gcc/fortran/frontend-passes.c:3059 0x7eae1a gfc_run_passes(gfc_namespace*) /space/rguenther/src/gcc-11-branch/gcc/fortran/frontend-passes.c:156 0x70e567 gfc_resolve(gfc_namespace*) /space/rguenther/src/gcc-11-branch/gcc/fortran/resolve.c:17445 0x70e567 gfc_resolve(gfc_namespace*) /space/rguenther/src/gcc-11-branch/gcc/fortran/resolve.c:17418 0x70ea29 update_current_proc_array_outer_dependency /space/rguenther/src/gcc-11-branch/gcc/fortran/resolve.c:3123 0x719a27 resolve_call /space/rguenther/src/gcc-11-branch/gcc/fortran/resolve.c:3750
Fixed on master with r12-5847-gb77968a70537429b and yes, gcc 11.3.0 fixed that.