Your linked question's (Does the C/C++ ternary operator actually have the same precedence as assignment operators?) answer by @hvd shows the answer.
The C++ and C grammars for ?:
are different.
In C++, the rightmost operand is allowed to be an assignment expression (so the compiler [greedily] treats the =
are part of the ?:
) while in C the rightmost operand is a conditional-expression
instead. Thus in C as soon as the compiler hits the =
the analysis of ?:
is complete and it treats it as k = ( 21 > 3 ? 12 : j ) = 10
.