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++/68949] [5/6 Regression] Implicit initialization of array member silently miscompiling.


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68949

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, build_vec_init calls maybe_constant_init on
<<< Unknown tree: aggr_init_expr
  4
  __comp_ctor 
  D.2114
  (struct Sub *) <<< Unknown tree: void_cst >>> >>>;
During that, we call
cxx_eval_call_expression
on the ctor (__comp_ctor in particular).
That function does:
  if (DECL_CLONED_FUNCTION_P (fun))
    fun = DECL_CLONED_FUNCTION (fun);
so loses the notion on whether we wanted to call the base or comp ctor.
And then we run into:
          if (DECL_SAVED_TREE (fun) == NULL_TREE
              && (DECL_CONSTRUCTOR_P (fun) || DECL_DESTRUCTOR_P (fun)))
            /* The maybe-in-charge 'tor had its DECL_SAVED_TREE
               cleared, try a clone.  */
            for (fun = DECL_CHAIN (fun);
                 fun && DECL_CLONED_FUNCTION_P (fun);
                 fun = DECL_CHAIN (fun))
              if (DECL_SAVED_TREE (fun))
                break;
          gcc_assert (DECL_SAVED_TREE (fun));
and just pick randomly one of the ctors, and depending on which one we pick we
either get the base or comp ctor behavior.
Now, for whatever reason, in the "good" compiler the __base_ctor (which is the
first clone) has DECL_SAVED_TREE non-NULL and __comp_ctor DECL_SAVED_TREE NULL
(the former being:
<<cleanup_point <<< Unknown tree: expr_stmt
  (void) (*(struct 
  {
    int i;
  } &) this = {CLOBBER}) >>>>>;
<<cleanup_point <<< Unknown tree: expr_stmt
  (void) (*(struct 
  {
    int i;
  } &) this = {CLOBBER}) >>>>>;
{
  <<cleanup_point <<< Unknown tree: expr_stmt
  (void) (((struct Sub *) this)->i = -1) >>>>>;
}
) and in the "bad" compiler the __base_ctor has DECL_SAVED_TREE NULL and
__comp_ctor has DECL_SAVED_TREE non-NULL,
<<cleanup_point <<< Unknown tree: expr_stmt
  (void) (*(struct 
  {
    int i;
  } &) this = {CLOBBER}) >>>>>;

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