Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!sun!pitstop!sundc!seismo!uunet!mcvax!unido!sbsvax!greim From: greim@sbsvax.UUCP (Michael Greim) Newsgroups: comp.lang.c Subject: Compiler Error? Keywords: "?:" precedence cc pcc assignment 43BSD SunOS Message-ID: <683@sbsvax.UUCP> Date: 14 Feb 89 18:03:06 GMT Organization: Universitaet des Saarlandes, Saarbruecken, W-Germany Lines: 44 This is about pre-ANSI C. Consider the following program: ------ cut ------------------- # include main () { int i, j, k; i = 5; j = 0; k = 0; if (i == 5) (j = 2) ? k = 3 : 4; printf ("j = %d, k = %d\n", j, k); } ------- cut ----------------- On 43BSD, SunOS 3.4, ULTRIX 2.0 this compiles with no error. According to the C books I could get my hands on, "?:" has higher precedence than the assignment operators, like "=" for instance. (In X3J11 too) Thus the compiler should find an error in the statement, something like "misplaced assignment". SIEMENS SINIX v2.1 finds an error. Is it really a compiler error? In all the major compilers? And nobody has noticed it yet? :-) Is it a typical pcc error? How does GNU perform? What about the ANSI compilers? -mg PS.: I found such a statement in GNU grep, when I was porting it to SINIX. -- email : greim@sbsvax.informatik.uni-saarland.dbp.de (some mailers might not like this. Then use greim@sbsvax.uucp) or : ...!uunet!unido!sbsvax!greim # include