https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71565
Bug ID: 71565 Summary: INTENT(IN) polymorphic argument with pointer components - reject valid code Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: mrestelli at gmail dot com Target Milestone: --- (This was also discussed on comp.lang.fortran: https://groups.google.com/forum/#!topic/comp.lang.fortran/dPaOv53SGeA ) gfortran refuses to compile s1 in the attached code (while accepting s2 and s3 which do essentially the same thing): $ gfortran -c test.f90 -o test.o test.f90:17:3: select type(var); class is(t_b) 2 var%i = 3 1 Error: Associate-name »var« can not appear in a variable definition context at (1) because its target at (2) can not, either $ gfortran --version GNU Fortran (GCC) 7.0.0 20160615 (experimental) This seems a bug in gfortran, since the assignment defines the target of the pointer, not the pointer itself. Here is the code module m implicit none type, abstract :: t_a end type t_a type, extends(t_a), abstract :: t_b integer, pointer :: i => null() end type t_b contains subroutine s1(var) class(t_a), intent(in) :: var select type(var); class is(t_b) var%i = 3 end select end subroutine s1 subroutine s2(var) class(t_b), intent(in) :: var var%i = 3 end subroutine s2 subroutine s3(var) class(t_a), intent(in) :: var integer, pointer :: tmp select type(var); class is(t_b) tmp => var%i tmp = 3 end select end subroutine s3 end module m