[Omp] copy constructor vs. operator= when initializing firstprivate variables

Richard Henderson rth at twiddle.net
Tue Jul 11 17:48:42 PDT 2006


On Tue, Jul 11, 2006 at 04:38:23PM -0700, Chunhua Liao wrote:
> 1. Why do we have this specific requirement of using copy constructor here ?

Because that's how a new variable is initialized.  Compare with

class S
{
  private:
    S& operator= (const S&);
  public:
    S();
    S(const S&);
};

void foo (S *p)
{
  S s = *p;
}

> 2. Is it legal for a compiler to use operator= to do the same work?

No.  The operator= method will assume that the destination variable
was previously initialized, which isn't true.


r~


More information about the Omp mailing list