http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54322
Bug #: 54322 Summary: [OOP] Wrong TARGET-attribute handling with CLASS IS/TYPE IS Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Keywords: accepts-invalid, diagnostic Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: bur...@gcc.gnu.org CC: ja...@gcc.gnu.org Reported at comp.lang.fortran, https://groups.google.com/forum/?fromgroups#!topic/comp.lang.fortran/11t7gAgUGD4 The following piece of the program is invalid if PC_ALLOC is not a TARGET, however, gfortran accepts it: select type ( AN => pc_alloc ) type is ( POINT_3D ) p3d_poi=>AN Note that this possibly not only affects pointer assignment but also passing as actual argument to an INTENT(IN) pointer dummy, and possibly other cases. !------------- LONG TEST CASE --------------- module mymod type POINT real :: X, Y contains procedure :: s1 => sub1 end type POINT type, extends(POINT) :: POINT_3D real :: Z end type POINT_3D type, extends(POINT) :: COLOR_POINT integer :: COLOR end type COLOR_POINT contains subroutine sub1(this) class(POINT) :: this end subroutine sub1 end module mymod !================================================ program hello use mymod implicit none type(POINT), target :: P type(POINT_3D), target :: P3D type(COLOR_POINT), target :: CP class(POINT), pointer :: P_OR_CP class(POINT),allocatable::pc_alloc !NO "TARGET" class(POINT_3D),pointer ::p3d_poi P_OR_CP=> CP allocate (POINT_3D :: pc_alloc) pc_alloc%X=1. pc_alloc%Y=2. select type ( AN => pc_alloc ) class is ( POINT ) ! print *, AN%X, AN%Y type is ( POINT_3D ) AN%Z=3. p3d_poi=>AN ! INVALID if PC_ALLOC is not a TARGET end select print *, p3d_poi%X, p3d_poi%Y, p3d_poi%Z end program