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



--- Comment #4 from janus at gcc dot gnu.org 2012-10-04 13:44:45 UTC ---

Note that, in a way, this 'double mangling' is not a bug but a feature.



It was introduced for PR 46313, in order to handle cases like the one below.

(There might be other ways to deal with this, though.)





module m1

  implicit none

  type mytype

  end type mytype

  type,extends(mytype) :: mytype2

    integer :: a(10) = 2

  end type mytype2

contains

  subroutine test1()

    class(mytype), allocatable :: a1, a2

    allocate (a1, source=mytype2())

    allocate ( a2, source=a1)

    select type (a2)

      type is (mytype2)

        print *, a2%a

    end select

    deallocate  (a2)

    allocate ( a2, mold=a1)

    select type (a2)

      type is (mytype2)

        print *, a2%a

    end select

  end subroutine test1

end module m1



module m2

  implicit none

  type mytype

  end type mytype

  type,extends(mytype) :: mytype2

    integer :: b(10) = 8

  end type mytype2

contains

  subroutine test2()

    class(mytype), allocatable :: b1, b2

    allocate (b1, source=mytype2())

    allocate ( b2, source=b1)

    select type (b2)

      type is (mytype2)

        print *, b2%b

    end select

    deallocate  (b2)

    allocate ( b2, mold=b1)

    select type (b2)

      type is (mytype2)

        print *, b2%b

    end select

  end subroutine test2

end module m2



use m1, only: test1

use m2, only: test2

implicit none

call test1()

call test2()

end

Reply via email to