https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79739
Bug ID: 79739 Summary: ICE with some interesting code Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: jvdelisle at gcc dot gnu.org Target Milestone: --- Three files. While testing some threading concept. Note: This is not an actual coarray program. Compile with: gfortran -fopenmp cafmain.f90 cafi.f90 caf.f90 Compiles and runs fine with gfortran 6.3, Latest trunk fails on compile. cafi.f90: module cafi !! Implement ../libcaf.h, mapping each imagee to an OpenMP thread use iso_c_binding, only : c_int,c_char,c_ptr implicit none private public :: this_image public :: num_images public :: caf_init public :: caf_finalize character(len=8,kind=c_char), parameter :: prefix="_gfortran_" interface module subroutine caf_init(argc,argv) bind(C,name="_gfortran_caf_init") !! Fork all threads implicit none type(c_ptr), value :: argc, argv end subroutine module subroutine caf_finalize() bind(C,name="_gfortran_caf_finalize") !! Join all threads implicit none end subroutine module subroutine caf_register() bind(C,name="_gfortran_caf_register") !! Register implicit none end subroutine module function this_image() bind(C,name="_gfortran_caf_this_image") result(image_num) !! Return the thread number as the image number implicit none integer(c_int) :: image_num end function module function num_images() bind(C,name="_gfortran_caf_num_images") result(num_images_) !! Return the number of threads as the number of images implicit none integer(c_int) :: num_images_ end function end interface end module cafi caf.f90: submodule(cafi) cafimp implicit none contains module procedure caf_init end procedure module procedure caf_finalize end procedure module procedure this_image use omp_lib, only : omp_get_thread_num image_num = omp_get_thread_num() + 1 end procedure module procedure num_images use omp_lib, only : omp_get_num_threads num_images_ = omp_get_num_threads() end procedure module procedure caf_register end procedure end submodule caf_main.f90: module cafomp use cafi public :: cafrun procedure(), pointer :: myapp interface module function cafrun (cafapp) procedure(), pointer :: cafapp end function end interface contains function cafrun(cafapp) integer :: cafrun !$omp parallel call cafapp !$omp end parallel cafrun = 0 end function end module cafomp program hello use cafomp implicit none integer :: run myapp => userstuff run = cafrun ( myapp ) contains subroutine userstuff print *, "Greetings from image ",this_image()," of ",num_images() end subroutine end program