On Wed, 5 Sep 2018, Jakub Jelinek wrote: > On Wed, Sep 05, 2018 at 12:55:55PM +0200, Richard Biener wrote: > > > > The following makes sure to call the default CTOR when emplacing a > > vec<> in the avail hash-map. Certainly the intent was to zero-initialize > > the m_vec member. > > Guess it would be nice to see what older versions of system g++ do with > that. > At least from what I remember last time, value-initialization vs. > zero-initialization vs. no initialization in C++ is heavily dependent on > compiler version and -std=c++NN version, there have been many bugs in the > past and changes between standard versions.
It looks like g++ 4.8 puts extra zero-init with () but not without: - (void) (struct vec *) operator new (8, (void *) TARGET_EXPR <D.107094, (struct vec *) av>) >>>>>; + (void) (TARGET_EXPR <D.107096, (void *) TARGET_EXPR <D.107094, (struct vec *) av>>;, TARGET_EXPR <D.107095, operator new (8, NON_LVALUE_EXPR <D.107096>)>;;, (struct vec *) D.107095 != 0B ? *(struct vec *) D.107095 = {.m_vec=0B};, (struct vec *) D.107095; : (struct vec *) D.107095;) >>>>>; but yes, another option would be to explicitely do the following. Cheaper av.m_vec = NULL doesn't work because m_vec is poisoned... Index: gcc/tree-ssa-sccvn.c =================================================================== --- gcc/tree-ssa-sccvn.c (revision 264123) +++ gcc/tree-ssa-sccvn.c (working copy) @@ -5798,7 +5798,8 @@ rpo_elim::eliminate_push_avail (basic_bl vec<std::pair<int, int> > &av = m_rpo_avail.get_or_insert (valnum, &existed); if (!existed) { - new (&av) vec<std::pair<int, int> >; + new (&av) vec<std::pair<int, int> >(); + memset (&av, 0, sizeof (vec<std::pair<int, int> >)); av.reserve_exact (2); } av.safe_push (std::make_pair (bb->index, SSA_NAME_VERSION (leader))); > > 2018-09-05 Richard Biener <rguent...@suse.de> > > > > PR bootstrap/87134 > > * tree-ssa-sccvn.c (rpo_elim::eliminate_push_avail): Make sure > > to zero-init the emplaced vec. > > > > Index: gcc/tree-ssa-sccvn.c > > =================================================================== > > --- gcc/tree-ssa-sccvn.c (revision 264123) > > +++ gcc/tree-ssa-sccvn.c (working copy) > > @@ -5798,7 +5798,7 @@ rpo_elim::eliminate_push_avail (basic_bl > > vec<std::pair<int, int> > &av = m_rpo_avail.get_or_insert (valnum, > > &existed); > > if (!existed) > > { > > - new (&av) vec<std::pair<int, int> >; > > + new (&av) vec<std::pair<int, int> >(); > > av.reserve_exact (2); > > } > > av.safe_push (std::make_pair (bb->index, SSA_NAME_VERSION (leader))); > > Jakub > > -- Richard Biener <rguent...@suse.de> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)