Re: ternary expression validity
- From: "Robert Gamble" <rgamble99@xxxxxxxxx>
- Date: 12 Jan 2006 15:57:37 -0800
slashdotcommacolon@xxxxxxxxxxx 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
.
- Follow-Ups:
- Re: ternary expression validity
- From: pete
- Re: ternary expression validity
- From: Chuck F.
- Re: ternary expression validity
- References:
- ternary expression validity
- From: slashdotcommacolon
- ternary expression validity
- Prev by Date: Re: float pointers
- Next by Date: Re: Why We Use C Than C++...
- Previous by thread: ternary expression validity
- Next by thread: Re: ternary expression validity
- Index(es):
Relevant Pages
|
|