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

--- Comment #4 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #3)
> Btw, what's a C++ testcase for this?

#include <utility>
#include <vector>
typedef std::vector<int> V;
V f(V&v){
  V r;
  r=std::move(v);
  return r;
}

Compiled with -O2, the optimized dump has

  MEM[(struct _Vector_impl_data *)r_2(D)]._M_start = 0B;
  _10 = MEM[(const struct _Vector_impl_data &)v_3(D)]._M_start;
  MEM[(struct _Vector_impl_data *)r_2(D)]._M_start = _10;
  MEM[(struct _Vector_impl_data *)v_3(D)]._M_start = 0B;

and the same for the 2 other fields, interleaved.
(ok, in this case we could prove that the vectors don't alias, but that's a
separate issue)

Reply via email to