http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48946
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011.05.18 20:06:33
Ever Confirmed|0 |1
--- Comment #1 from janus at gcc dot gnu.org 2011-05-18 20:06:33 UTC ---
(In reply to comment #0)
> 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_'
The dump shows that the assignment "one = two" is incorrectly translated to:
struct __class_foo_module_Foo class.1;
struct __class_foo_module_Foo class.0;
class.0._vptr = (struct __vtype_foo_module_Foo * {ref-all})
&__vtab_bar_module_Bar;
class.0._data = (struct foo *) &one;
class.1._vptr = (struct __vtype_foo_module_Foo * {ref-all})
&__vtab_bar_module_Bar;
class.1._data = (struct foo *) &two;
assign_interface (&class.0, &class.1);
First we generate two temporaries to convert the TYPE variables to CLASS
arguments, which is fine. However, the last line should be a polymorphic call
like
class.0._vptr->assign (&class.0, &class.1);
Btw, it works when making the first argument polymorphic:
program main
use bar_module
implicit none
class(bar), allocatable :: one
type(bar) :: two
allocate(one)
one%x = 1
two%x = 2
one = two
end program