https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80392
Bug ID: 80392 Summary: ICE with allocatable polymorphic function result in a procedure pointer component Product: gcc Version: 7.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: zed.three at gmail dot com Target Milestone: --- Very similar to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68196 and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56385 but making the function result polymorphic: module mwe implicit none type :: MyType procedure(my_op), nopass, pointer :: op end type MyType abstract interface function my_op() result(foo) import class(MyType), allocatable :: foo end function my_op ! Replacing with subroutine works ! subroutine my_op(foo) ! import :: MyType ! class(MyType), allocatable :: foo ! end subroutine my_op end interface contains subroutine bad_sub(op) procedure(my_op) :: op end subroutine bad_sub end module mwe With gfortran 4.8.5, 5.4.1, and 6.2.1, I get the following error (which I think might be wrong as well?): mwe.f90:23:23: subroutine bad_sub(op) 1 Error: CLASS variable ‘op’ at (1) must be dummy, allocatable or pointer With gfortran 7.0.1, I get an ICE: gfortran-7: internal compiler error: Segmentation fault (program f951) I also get an ICE with 5.4.1 and 6.2.1 (but not 4.8.5) if I remove the `bad_sub` implementation. Changing the interface to the commented-out subroutine instead of a function, and everything works. Also, changing foo to be a pointer rather than allocatable makes the ICE go away.