In the code below, why doesn't the assignment to get_string_val() give compilation error ? It looks like the function is returning an rvalue.
Of course, this is a simple example and this could be a member function returning a member variable. This can cause a bad bug if I had intended to return std::string& but mis-typed and returned std::string.
It looks like "xxx" is getting assigned to a temporary variable returned by get_string_val() ?
std::string get_string_val()
{
std::string x;
return x;
}
int main()
{
get_string_val() = "xxx";
}