------- Comment #6 from jamborm at gcc dot gnu dot org 2009-10-27 13:59 ------- The problem here is that build_ref_for_offset_1() cannot find a field corresponding to a replacement within its own aggregate. The field is identified by its offset (zero) and type. Unfortunately, types_compatible_p() claims that the type of the replacement (taken from the expression where it occurs) and the field at the offset are not compatible. I have added some dumps to the beginning of the function and got:
---------------------------------------------------------------------- picked field value Determining compatibility of types: Expected type (type of the scalar replacement): <pointer_type 0xb7726514 type <union_type 0xb772612c tree_node SI size <integer_cst 0xb7687498 constant 32> unit size <integer_cst 0xb7687284 constant 4> align 32 symtab 0 alias set -1 canonical type 0xb772612c fields <field_decl 0xb76eee60 common type <record_type 0xb7720b54 tree_common> SI file b.h line 8 col 20 size <integer_cst 0xb7687498 32> unit size <integer_cst 0xb7687284 4> align 32 offset_align 128 offset <integer_cst 0xb76872a0 constant 0> bit offset <integer_cst 0xb7687700 constant 0> context <union_type 0xb772612c tree_node> chain <field_decl 0xb76eef18 constructor>> pointer_to_this <pointer_type 0xb7726514>> unsigned SI size <integer_cst 0xb7687498 32> unit size <integer_cst 0xb7687284 4> align 32 symtab 0 alias set 4 canonical type 0xb7726514> Record field type: <pointer_type 0xb7720e10 type <union_type 0xb7720af0 tree_node SI size <integer_cst 0xb7687498 constant 32> unit size <integer_cst 0xb7687284 constant 4> align 32 symtab 0 alias set -1 canonical type 0xb7720af0 fields <field_decl 0xb76eebdc common type <record_type 0xb7720b54 tree_common> SI file b.h line 8 col 20 size <integer_cst 0xb7687498 32> unit size <integer_cst 0xb7687284 4> align 32 offset_align 128 offset <integer_cst 0xb76872a0 constant 0> bit offset <integer_cst 0xb7687700 constant 0> context <union_type 0xb7720af0 tree_node> chain <field_decl 0xb76eec94 constructor>> pointer_to_this <pointer_type 0xb7720e10>> unsigned SI size <integer_cst 0xb7687498 32> unit size <integer_cst 0xb7687284 4> align 32 symtab 0 alias set 3 canonical type 0xb7720e10> NOT compatible. ---------------------------------------------------------------------- I could workaround this and check whether all replacements can be located within their aggregates before creating them but that does not sound right. Instead I think that the bug is either somewhere in type merging or in types_compatible_p(). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41767