https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119889
--- Comment #5 from Jürgen Reuter <juergen.reuter at desy dot de> --- (In reply to anlauf from comment #4) > It fails for all gfortran versions since at least 7. > > NAG says: > > Panic: pr119889.f90, line 59: Impossible no interface > Internal Error -- please report this bug > > This might give a hint where to look. > > Interestingly, replacing > > procedure(dlsym), pointer :: tmp_fun > > by > > procedure(), pointer :: tmp_fun > > lets the code compile. And comparing the fortran-dump: > > Failing: > > symtree: 'tmp_fun' || symbol: 'tmp_fun' > type spec : (UNKNOWN 0) > attributes: (PROCEDURE EXTERNAL FUNCTION ARRAY-OUTER-DEPENDENCY > ALWAYS-EXPLICIT PROC-POINTER UNTYPED IFSRC-IFBODY) > result: tmp_fun > > Workaround: > > symtree: 'tmp_fun' || symbol: 'tmp_fun' > type spec : (UNKNOWN 0) > attributes: (PROCEDURE EXTERNAL SUBROUTINE ARRAY-OUTER-DEPENDENCY > PROC-POINTER) > > > > Playing around, I arrive at the following reduced testcase: > > module ol_dlfcn > use, intrinsic :: iso_c_binding, only: c_ptr, c_null_ptr > implicit none > > type process_handle > type(c_ptr) :: library_handle = c_null_ptr > end type process_handle > > contains > > function dlsym() result(f_funp) > procedure(), pointer :: f_funp > f_funp => null() > end function dlsym > > function get_process_handle() > type(process_handle) :: get_process_handle > procedure(dlsym), pointer :: tmp_fun ! -> ICE > ! procedure(), pointer :: tmp_fun ! -> no ICE > ! number of external particles > !!! Triggers the ICE > tmp_fun => dlsym() > end function get_process_handle > > end module ol_dlfcn > > > This gives the same failures with NAG, Intel, and gfortran. > > We need to check if the code is standard conforming. Hi Harald, as I reported this to NAG and Intel as well, I got the following reply from Malcolm Cohen from NAG: "I note that there is an error in your example at line 56: it has procedure(dlsym), pointer :: tmp_fun however, it is not being pointer-assigned dlsym, but the result of referencing dlsym. Therefore it should be something like procedure(), pointer :: tmp_fun" After correcting this, both Nagfor and Ifx compile, as in gfortran. Cheers, Jürgen