https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81447
Bug ID: 81447 Summary: gfortran fails to recognize the exact dynamic type of a polymorphic entity that was allocated in a external procedure Product: gcc Version: 7.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: mathewc at nag dot co.uk Target Milestone: --- > uname -a && gfortran --version && cat foo.f90 && gfortran foo.f90 && ./a.out Linux cuivienen.nag.co.uk 4.11.9-300.fc26.x86_64 #1 SMP Wed Jul 5 16:21:56 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux GNU Fortran (GCC) 7.1.1 20170622 (Red Hat 7.1.1-3) Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Module m Type :: t End Type End Module Program p Use m Class (t), Allocatable :: x Interface Subroutine s(x) Use m Class (t), Allocatable :: x End Subroutine End Interface Call s(x) Select Type (x) Type Is (t) Continue Class Is (t) Stop 'Inconceivable t' Class Default Stop 'Inconceivable *' End Select Print *, 'ok' End Program Subroutine s(x) Use m, Only: t Implicit None Class (t), Allocatable :: x Allocate (t :: x) End Subroutine STOP Inconceivable t Note that the version with s internal to p is OK: Module m Type :: t End Type End Module Program p Use m Class (t), Allocatable :: x Call s(x) Select Type (x) Type Is (t) Continue Class Is (t) Stop 'Inconceivable t' Class Default Stop 'Inconceivable *' End Select Print *, 'ok' Contains Subroutine s(x) Use m, Only: t Implicit None Class (t), Allocatable :: x Allocate (t :: x) End Subroutine End Program ok