http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46313

--- Comment #10 from janus at gcc dot gnu.org 2010-11-09 17:07:24 UTC ---
(In reply to comment #9)
> One way to fix this is to use the top-level namespace (i.e. program or module)
> for the naming of the internal symbols, instead of the direct parent namespace
> of the derived type (patch below).

Problem: This scheme produces wrong results for the following test case (which
is similar to comment #0, case c), since the vtabs for both types coincide:


implicit none

call test1()
call test2()

contains

  subroutine test1()
    type :: mytype
      integer :: a = 2
    end type mytype
    class(mytype), allocatable :: a1, a2
    print *,"test1"
    allocate (a1, source=mytype())
    allocate ( a2, source=a1)
    print *, a2%a
    deallocate  (a2)
    allocate ( a2, mold=a1)
    print *, a2%a
  end subroutine test1

  subroutine test2()
    type :: mytype
      integer :: b = 8
    end type mytype
    class(mytype), allocatable :: b1, b2
    print *,"test2"
    allocate (b1, source=mytype())
    allocate ( b2, source=b1)
    print *, b2%b
    deallocate  (b2)
    allocate ( b2, mold=b1)
    print *, b2%b
  end subroutine test2

end

Reply via email to