------- Additional Comments From mmitchel at gcc dot gnu dot org 2005-05-10 02:49 ------- The reason that this happens when the type assigned is a class types is that those types have overloaded operator=. There's always an implicit operator=, even if one is not declared explicitly, with a "this" argument of type "T*". So, we take the address of "conv.first" in preparation for passing it to the function. Now, in build_unary_op, we do this bit:
tree field = TREE_OPERAND (arg, 1); tree rval = build_unary_op (ADDR_EXPR, TREE_OPERAND (arg, 0), 0); tree binfo = lookup_base (TREE_TYPE (TREE_TYPE (rval)), decl_type_context (field), ba_check, NULL); rval = build_base_path (PLUS_EXPR, rval, binfo, 1); => rval = build_nop (argtype, rval); addr = fold (build (PLUS_EXPR, argtype, rval, cp_convert (argtype, byte_position (field)))); which destroys the COMPONENT_REF. This is rather silly. In more current compilers, we have actual FIELDs for the base classes, and we should just be chasing through them. Certainly, when the class containing the field and the class of the object are the same, there's no need for any of this. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20607