Consider the following code:
struct S
{
S& operator=(const S&) = default;
};
int main()
{
&(S() = S());
}
GCC (trunk) complains with:
error: taking address of rvalue [-fpermissive] 8 | &(S() = S()); | ~~~~~^~~~~~
I found the above error surprising, as I would expect an S&
return type to produce an lvalue expression. Clang (trunk), on the other hand, accepts the code without any error or warning.
What compiler is correct here?
Is
S() = S()
an rvalue or an lvalue?