This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/15461] [3.4 regression] ICE on valid code


------- Additional Comments From ebotcazou at gcc dot gnu dot org  2004-06-20 11:47 -------
I think the problem lies in the C++ front-end.

The ICE happens because the tree-inliner inserts a DECL_STMT corresponding to
the RESULT_DECL 'tv' when inlining the operator:

    arg 0 <compound_stmt 0x4024b488
        arg 0 <scope_stmt 0x4024b4c4 tree_0 tree_3
            arg 0 <block 0x4024c118 used vars <var_decl 0x4024a6c0 this>
abstract_origin <function_decl 0x40248a20 operator 1>>
            chain <decl_stmt 0x4024b4b0 arg 0 <var_decl 0x4024a6c0 this>
-->             chain <decl_stmt 0x4024b4ec arg 0 <var_decl 0x4024a798 tv>
                    chain <compound_stmt 0x4024b500 tree_1 tree_2 tree_3
                        arg 0 <scope_stmt 0x4024b514 tree_0 tree_1 arg 0 <block
0x4024c140>
                        chain <compound_stmt 0x4024b528>>

Now the VAR_DECL of 'tv' has a constructor as its DECL_INITIAL, and the
constructor references the VAR_DECL of 'sec'.  But the declaration of 'sec' has
not yet been seen so the compiler invokes make_decl_rtl on a automatic variable
and aborts on the entry sanity check.

I'm not sure how this should work.  In the 3.3.x series, the DECL_STMT is not
inserted by tree-inline.c:declare_return_variable

  /* Build the declaration statement if FN does not return an
     aggregate.  */
  if (need_return_decl)
    return build_stmt (DECL_STMT, var);

because FN (the operator) is recognized as returning an aggregate.

In the 3.4.x series, this is not true because CALL_EXPR_HAS_RETURN_SLOT_ADDR
is not set by simplify_aggr_init_exprs_r/simplify_aggr_init_expr (there is no
AGGR_INIT_EXPR in the tree).  So it would appear that the front-end has
optimized away the aggregate-ness of struct A.

Maybe the fix is to remove the DECL_INITIAL when the RESULT_DECL is copied to
the VAR_DECL in cp_copy_res_decl_for_inlining.  Or maybe it is to treat the
operator as returning an aggregate like in the 3.3.x series.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot gnu dot
                   |                            |org
         AssignedTo|ebotcazou at gcc dot gnu dot|unassigned at gcc dot gnu
                   |org                         |dot org
             Status|ASSIGNED                    |NEW
          Component|middle-end                  |c++


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15461


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]