http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46313
Summary: [OOP] OOP-ABI issue, ALLOCATE issue, CLASS renaming issue Product: gcc Version: 4.6.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: bur...@gcc.gnu.org There are a couple of issues which prevent the following program from working. (a) and (b) are compile time issues and (c) is a link-time issue (OOP ABI) a) It fails to compile with: allocate ( t1 :: a1) 1 Error: Error in type-spec at (1) b) Working around this issue, as in allocate (a1, source=t1()) allocate (b1, source=t2()) yields the error print *, b2%b 1 Error: 'b' at (1) is not a member of the 'mytype' structure Using Cray ftn, the result is: 10*2. 10*8. !---------------------------------------- module m1 type mytype real :: a(10) = 2 end type mytype end module m1 module m2 type mytype real :: b(10) = 8 end type mytype end module m2 use m1, t1 => mytype use m2, t2 => mytype implicit none class(t1), allocatable :: a1, a2 class(t2), allocatable :: b1, b2 allocate ( t1 :: a1) allocate ( t2 :: b1) allocate ( a2, source=a1) allocate ( b2, source=b1) !allocate ( a2, mold=a1) !allocate ( b2, mold=b1) print *, a2%a print *, b2%b end !---------------------------------------- (c) The following fails to link as the VTABLE only encodes the type name and not the module name: /tmp/ccBQh5fR.s: Assembler messages: /tmp/ccBQh5fR.s:401: Error: symbol `copy$mytype2_' is already defined /tmp/ccBQh5fR.s:431: Error: symbol `copy$mytype_' is already defined !---------------------------------------- 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 !----------------------------------------