Re: ternary expression validity



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

.



Relevant Pages

  • Re: Angband with an accent: displaying extended characters
    ... I'd certainly expect a port to be possible, ... >> About platform stuff, the ideal situation would be if all platform dependent ... >> We are at least not in a hurry to remove support for RISCOS, ... future and which ones are lost cases that none care or compile for anymore. ...
    (rec.games.roguelike.angband)
  • ANNOUNCE: DJGPP port of FreeBE/AF 1.2 uploaded.
    ... This is a port of FreeBE/AF 1.2 to MSDOS/DJGPP. ... DJGPP specific changes. ... Please note that I have no hardware to test if the drivers really work. ... To compile this program the allegro library and certain ...
    (comp.os.msdos.djgpp)
  • Re: upgrage from 4.1.2 to 4.3.3+?
    ... > every available RPM for the distro...and there isn't one for PHP. ... > And also, I uh, don't believe I've ever recompiled Apache or PHP. ... Well - You could compile your own version of Apache and PHP and place it ... port number - By this I mean, whenever you visit a website, it defaults ...
    (comp.lang.php)
  • Re: [9fans] Modularizing plan9port
    ... And a port of of plan9's awk? ... Right after compile several checks ... package is committed to the production systems. ...
    (comp.os.plan9)
  • Re: ImageMagick on 5.2-RC1 fails with pthread error (libkse)
    ... ImageMagick with threads, and I'm also libmap'ing libc_r to libkse. ... > need to update the port Makefile to include the correct thread ... The port maintainer is set to ports@freebsd.org, ... This allows the compile to finish and the port to install, ...
    (freebsd-current)