Garbage appears in vector after inserting result of operator
<p>I have an object with an operator defined like this:</p>

<pre><code>P&amp; operator +(const P &amp;rhs) {
    return P(x + rhs.x, y + rhs.y, z + rhs.z);
}
</code></pre>

<p>It does not have custom copy or assignment operators.</p>

<p>After I assign directly the result of an addition inside the vector, garbage appears inside it.</p>

<pre><code>P p1(1.0, 0.0, 0.0);
P p2(0.0, 0.0, 0.0);

vector&lt;P&gt; v(1);
v[0] = p1 + p2; // v[0] now contains garbage.
</code></pre>

<p>If I do it through a variable, everything is as expected.</p>

<pre><code>vector&lt;P&gt; u(1);
P q = p1 + p2;
u[0] = q; // u[0] contains correct value.
</code></pre>

<p>What can be the reason for such behavior? What is the difference between the two cases?</p>
