Why is it illegal to take the address of an rvalue temporary?
<p>According to " <a href="http://stackoverflow.com/questions/8763043/how-to-go-around-the-warning-rvalue-used-as-lvalue">How to get around the warning &quot;rvalue used as lvalue&quot;?</a> ", Visual Studio will merely warn on code such as this:</p>

<pre><code>int bar() {
   return 3;
}

void foo(int* ptr) {

}

int main() {
   foo(&amp;bar());
}
</code></pre>

<p>In C++ it is <em>not allowed</em> to take the address of a temporary (or, at least, of an object referred to be an <em>rvalue</em> expression?), and I thought that this was because temporaries are not guaranteed to even have storage.</p>

<p>But then, although diagnostics may be presented in any form the compiler chooses, I'd still have expected MSVS to <em>error</em> rather than <em>warn</em> in such a case.</p>

<p>So, are temporaries guaranteed to have storage? And if so, why is the above code disallowed in the first place?</p>
