Is this code valid?
int foo()
{
std::vector& v = std::vector(5, \"X\");
// Do something silly...
You have a reference to a deallocated object. It works by 'sheer luck' (see The C++ Programming Language, section 10.4.10 Temporary Objects). You can't guarantee that it'll work in every compiler.
You can only be certain that the lifetime of the temporary is extended if it's bound to a const reference.