A
Armen Tsirunyan
Hi all,
I clearly remember from the C++03 standard that a function call is an
lvalue if and only if it returns a reference.
Now I was reading C++ In A Nutshell book, and it says that
object.name, provided name is a nonstatic data member, is an lvalue if
and only if object is an lvalue. And we all know that the built-in
prefix ++ requires an lvalue. All that taken into consideration, I
tried to compile the following code on MSVC9.0
//code begins here
struct x
{
int z;
};
x f()
{
x ret;
ret.z = 0;
return ret;
}
int main()
{
++(f().z);
}
//end of code
And it did compile. Any comments?
I clearly remember from the C++03 standard that a function call is an
lvalue if and only if it returns a reference.
Now I was reading C++ In A Nutshell book, and it says that
object.name, provided name is a nonstatic data member, is an lvalue if
and only if object is an lvalue. And we all know that the built-in
prefix ++ requires an lvalue. All that taken into consideration, I
tried to compile the following code on MSVC9.0
//code begins here
struct x
{
int z;
};
x f()
{
x ret;
ret.z = 0;
return ret;
}
int main()
{
++(f().z);
}
//end of code
And it did compile. Any comments?