User account creation filtered due to spam.

Bug 54322 - [OOP] Wrong TARGET-attribute handling with CLASS IS/TYPE IS
Summary: [OOP] Wrong TARGET-attribute handling with CLASS IS/TYPE IS
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: accepts-invalid, diagnostic
Depends on:
Reported: 2012-08-19 15:33 UTC by Tobias Burnus
Modified: 2015-10-13 18:20 UTC (History)
1 user (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2015-10-13 00:00:00


Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2012-08-19 15:33:49 UTC
Reported at comp.lang.fortran,!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 )

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

      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


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)


   select type ( AN => pc_alloc )
      class is ( POINT )
!      print *, AN%X, AN%Y

      type is ( POINT_3D )
         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
Comment 1 Dominique d'Humieres 2015-10-13 18:20:22 UTC
Still present at r228753.