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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
As well as checking that destructors free an "owned" member, check that move
constructors and move assignments transfer ownership correctly, i.e. leave the
previous owner empty, and for move assignment, ensure any previous value in the
LHS is freed before being replaced i.e. given class Foo with member
gsl::owner<T*> m_ptr:

Foo&
Foo::operator=(Foo& rhs)
{
  m_ptr = rhs.m_ptr;
  rhs.m_ptr = nullptr;
  return *this;
}

flag a bug, because the previous value of m_ptr is overwritten without freeing
it.

Reply via email to