I just ran into some kind of weirdness related to this. It seems that the result of the triple conditional expression can be considered as an lvalue in gcc 3.3.2, but not in gcc 4.6 (I have no other versions ready for hand to narrow it further). In fact, it is not possible to compile gcc 3.3.2 using gcc 4.6 precisely because gcc 4.6 sorts a lot about what constitutes lvalue.
Another example is from gcc 3.3.2 source that does not compile with gcc 4.6:
char *x = ...; *((void**)x)++ = ...;
gcc 4.6 can process the cast result as an lvalue and increment it, but gcc 4.6 will not.
I also do not have the relevant standards to find out about this, is it something that has changed in the official standard or just something that gcc allowed at a certain stage.
Note also that C ++ allows the ternary operator to return an lvalue, although you still cannot increment 0. So this is valid C ++, but not valid C:
int c = 0, d = 0; (c?c:d)++;
source share