http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48059
--- Comment #7 from janus at gcc dot gnu.org 2011-03-11 14:45:22 UTC --- (In reply to comment #6) > I think the inputs to conv_parent_component_references are already wrong. > From the caller of that function (gfc_conv_variable): > > 755 case REF_COMPONENT: > 756 if (ref->u.c.sym->attr.extension) > 757>>> conv_parent_component_references (se, ref); > 758 > 759 gfc_conv_component_ref (se, ref); > > (gdb) p debug_generic_expr(se->expr) > *D.1572 > > (That's the b_type variable) > (gdb) p ref->u.c.sym->name > $55 = 0x7ffff7f47b28 "__class_a_module_A_type" > (gdb) p ref->u.c.component->name > $56 = 0x7ffff7e7ffa0 "length" > > So, it wants to get at the a_type.length member, but applies the whole > thing to a b_type'd variable. Yes, the base type in the reference is wrong. And the reason for this seems to be that it is not corrected in the interface mapping. I think we need to extend 'gfc_apply_interface_mapping_to_ref' to set the correct base type for polymorphic arguments.