This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/48946] New: [OOP] Deferred Overloaded Assignment
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 10 May 2011 10:11:14 +0000
- Subject: [Bug fortran/48946] New: [OOP] Deferred Overloaded Assignment
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48946
Summary: [OOP] Deferred Overloaded Assignment
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Keywords: rejects-valid, wrong-code
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: burnus@gcc.gnu.org
CC: janus@gcc.gnu.org
The FE wrongly resolves the operator, leading to "wrong code" in the sense that
the linker cannot find the symbol:
undefined reference to `assign_interface_'
Reported by Andrew Baldwin and reported to work with XLF and NAG.
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/32602f115b24e19d
Test case:
module foo_module
implicit none
type, abstract :: foo
contains
procedure (assign_interface), deferred :: assign
generic :: assignment(=) => assign
end type
abstract interface
subroutine assign_interface(lhs,rhs)
import :: foo
class(foo), intent(inout) :: lhs
class(foo), intent(in) :: rhs
end subroutine
end interface
end module
module bar_module
use foo_module
implicit none
type, extends(foo) :: bar
real :: x
contains
procedure :: assign => assign_bar
end type
contains
subroutine assign_bar(lhs,rhs)
class(bar), intent(inout) :: lhs
class(foo), intent(in) :: rhs
select type(rhs)
type is (bar)
lhs%x = rhs%x
end select
end subroutine
end module
program main
use foo_module
use bar_module
implicit none
type(bar) :: one, two
one%x = 1
two%x = 2
one = two
end program