For example:
int StrLen(const std::string &s = "default string") {
const std::string &t = "another string"; // BTW, is this line safe?
return s.size();
}
Update
SoapBox's conclusion is correct, but the reason is not completely right.
the lifetime of the temporary is automatically extended to be the same as the reference that holds it.
This is usually true with several exceptions. One is that
"A temporary bound to a reference parameter in a function call persists until the completion of the full-expression containing the call."
I think this exception applys for the default argument case.
Another exception is related to the additional example in SoapBox's answer:
"The lifetime of a temporary bound to the returned value in a function return statement is not extended; the temporary is destroyed at the end of the full-expression in the return statement."