https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80235
--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Andre Vehreschild <ve...@gcc.gnu.org>: https://gcc.gnu.org/g:e32fff675c3bb040fa79854f6b0654c16bc38997 commit r15-4405-ge32fff675c3bb040fa79854f6b0654c16bc38997 Author: Andre Vehreschild <ve...@gcc.gnu.org> Date: Tue Sep 24 14:30:52 2024 +0200 Fix ICE with coarrays and submodules [PR80235] Exposing a variable in a module and referencing it in a submodule made the compiler ICE, because the external variable was not sorted into the correct module. In fact the module name was not set where the variable got built. gcc/fortran/ChangeLog: PR fortran/80235 * trans-decl.cc (gfc_build_qualified_array): Make sure the array is associated to the correct module and being marked as extern. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/add_sources/submodule_1_sub.f90: New test. * gfortran.dg/coarray/submodule_1.f90: New test.