Is it legal to pass a newly constructed object by reference to a function?
<p>Specifically, is the following legal C++?</p>

<pre>class A{};

void foo(A*);
void bar(const A&);

int main(void)
{
    foo(&A());  // 1
    bar(A());  // 2
}</pre>

<p>It appears to work correctly, but that doesn't mean it's necessarily legal.  Is it?</p>

<p><i>Edit - changed <code>A&amp;</code> to <code>const A&amp;</code></i></p>
