I know that the code written below is illegal
void doSomething(std::string *s){}
int main()
{
doSomething(&std::string(\"Hello World\"));
retur
[...] it can be concluded that the temporary was present in some memory location
By definition:
So it doesn't take a very elaborate proof to show that a temporary has an address. This is by definition.
OTOH, you are not just fetching the address, you are using the builtin address-of operator. The specification of the builtin address-of operator says that you must have a lvalue:
&std::string() is ill-formed because std::string() is a rvalue. At runtime, this evaluation of this expression creates a temporary object as a side-effect, and the expression yield a rvalue that refers to the object created.&(std::string() = "Hello World") is well-formed because std::string() = "Hello World" is a lvalue. By definition, a lvalue refers to an object. The object this lvalue refers to is the exact same temporaryThis is the rule. It doesn't need the (incorrect, unsound) justifications some people are making up.