https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122772

--- Comment #2 from Halalaluyafail3 <luigighiron at gmail dot com> ---
(In reply to Richard Biener from comment #1)
> The C frontend also rejects this:
> 
> t.c: In function ‘main’:
> t.c:3:12: error: lvalue required as left operand of assignment
>     3 |     (x.x=0)+=0;
>       |            ^~
> 
> I think this is correct, an assignment produces an rvalue, not an lvalue.
> 
> int main(){
>     int a, b;
>     (a = b) = 0;
> }
> 
> is invalid.
Yes, in C assignment operators and comma operators never result in lvalues. In
C++ non-overloaded assignment operators will always result in an lvalue, and
non-overloaded comma operators will result in an lvalue if the second operand
is an lvalue. So this should be rejected in C and accepted in C++.

Reply via email to