http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53202

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-05-03 
01:14:28 UTC ---
If I change some of the functions to forward lvalues instead of using perfect
forwarding then I see one call to a copy constructor

e.g. just changing the thread::Impl ctor to

      Impl(const T& t) : t(t) { }

produces:

default ctor called, this=0x7fffd878f35f
copy ctor called
destructor called, this=0x7fffd878f327
void background_hello::operator()() called, this=0x1258010
destructor called, this=0x1258010
destructor called, this=0x7fffd878f35f

The gimple dump shows:

thread::Impl<T>::Impl(const T&) [with T = Bind_simple<background_hello>]
(struct Impl * const this, const struct Bind_simple & t)
{
  struct Bind_simple * D.8913;
  struct Bind_simple * D.8914;

  thread::ImplBase::ImplBase (this);
  D.8913 = &this->t;
  Bind_simple<background_hello>::Bind_simple (D.8913, t);
  try
    {

    }
  catch
    {
      D.8914 = &this->t;
      Bind_simple<background_hello>::~Bind_simple (D.8914);
    }
}

Note the copy construction of the Bind_simple member that was missing
previously

Reply via email to