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

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to rguent...@suse.de from comment #8)
> On Fri, 25 Sep 2020, redi at gcc dot gnu.org wrote:
> 
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97207
> > 
> > --- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
> > (In reply to Richard Biener from comment #4)
> > > That swap couldn't have worked before because auto_vec eventually 
> > > contains a
> > > pointer into itself.  So the patch has improved things from broken to
> > > rejected.  Rejected because while there's a move CTOR now, std::swap isn't
> > > happy with just that.
> > > 
> > > No idea why - Jonathan?
> > 
> > Because swap requires assignment, not just construction.
> > 
> > I don't see a libstdc++ bug here.
> 
> But there is assignment?  Just no move assignment?

No there isn't. You deleted the move assignment operator, so there's no
assignment at all.

Swap uses move assignment anyway.


> I guess swap
> is really special because clearly formerly
> 
>  {
>   auto_vec<int> a, b;
>   a.safe_push (1);
>   b = a;
>  }
> 
> would have caused a double-free.  std::swap fixes this because, well,
> it swaps.  Going to try implement move assignment then.
> 
> Just wonder why when move assingment is not there it doesn't
> fall back to non-move assignment semantics (aka previous behavior)

Because you deleted it, that says you don't want assignment.

Reply via email to