Get the latest tech news
Is `(expession, lvalue) = rvalue` a valid assignment in C or C++?
Some time ago I stumbled upon the idea of how a C construct, such as (expr0, expr1, expr2), evaluates (see "What does the comma operator , do?" for more context). I've started experimenting
I've started experimenting with this, especially inside of function-like macros, and recently found a code which is rejected by some compilers, while accepted by others. At first, I thought it's a bug within tcc, since it's the only C compiler which does not reject the "faulty" code, but then I checked C++ front-ends and I'm not so sure about it any more. In your example, arr[0] is an operand of the, operator, so should lose its lvalue-ness; so tcc is wrong, and the other C compilers are correct.
Or read this on Hacker News