https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99183

            Bug ID: 99183
           Summary: Incompatible Runtime types
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: drikosev at gmail dot com
  Target Milestone: ---

Having post a question in c.l.f I was informed that the program below is
invalid but gfortran accepts it (several versions). This is the question:
https://groups.google.com/g/comp.lang.fortran/c/jWHX3kJMeYY/m/4IMgy19hDgAJ

Hope it isn't a duplicate!

$ gfortran8 dream-casting.f90 && ./a.out
 allocated    x = d1(ind=1,i=1)
 allocated    v = d2(ind=2,j=2)
 assigned v = x,  now v%ind=           1 j=           1
$ cat dream-casting.f90
program test
    implicit none

  type :: d0
    integer :: ind
  end type d0

  type, extends(d0) :: d1
    integer :: i
  end type d1

  type, extends(d0) :: d2
    integer :: j
  end type d2

  class(d1),      allocatable :: x
  class(d2),      allocatable :: v

  allocate ( x ,    source = d1(1,1))
  print *, "allocated    x = d1(ind=1,i=1)"

  allocate ( v ,    source = d2(2,2))
  print *, "allocated    v = d2(ind=2,j=2)"

  v = x
  print *, "assigned v = x,  now v%ind=", v%ind, "j=", v%j

end program test

Reply via email to