Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!mcsun!hp4nl!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.lang.c Subject: precedence of && (was: precedence of ?:) Message-ID: <3236@solo10.cs.vu.nl> Date: 12 Sep 89 21:39:12 GMT References: <1265@gmdzi.UUCP> <11030@smoke.BRL.MIL> <11039@smoke.BRL.MIL> Organization: V.U. Informatica, Amsterdam, the Netherlands Lines: 24 gwyn@smoke.BRL.MIL (Doug Gwyn) writes: [... Must 0 ? 0 : i = 0 be parsed as (0) ? (0) : (i=0) or as (0 ? 0 : i) = 0 ? ...] \ \OOPS! As Steve Emmerson was the first to point out to me, the correct \way to parse expressions in C is to follow the formal grammar reduction \rules, not rely on the precedence/associativity tables. Because the \left operand in an assignment expression cannot be a conditional \expression (it is constrained to be a unary expression with lvalueness), \there is no legal way to parse the example into the second form. Thus \I was mistaken, as were the compiler implementors who parsed it that \way. Perhaps they made the same mistake I just did. Then how about the following, Doug? "There is no legal way to parse..." 0 && i = 0 -- C, the programming language that's the same |Maarten Litmaath @ VU Amsterdam: in all reference frames. |maart@cs.vu.nl, mcvax!botter!maart