wrote:
> Hello, I've been asked to port some old code to a new platform. We have
> a vendor-supplied compiler that is supposed to be ansi compliant, but
> it refuses to compile the following code:
>
> $ cat test.c
> int main(int argc, char **argv)
> {
> static int a, b, c, d, e, f, g, h, i, j, k;
>
> return k = a ? b++, c : d ? e++, f : g ? h++, i : j;
> }
The code above is valid and should compile properly. I happen to think
that the last statement is very poorly written though, I wouldn't want
to see the rest of the code written by the guy who came up with this
gem. This is the type of code that leads to bugs and maintenance
nightmares, especially if you forget that the tertiary operator is
right-to-left associative.
Robert Gamble