Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!sdd.hp.com!spool.mu.edu!snorkelwacker.mit.edu!paperboy!hsdndev!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: The irregularity of the ?: operator Message-ID: <16030@smoke.brl.mil> Date: 2 May 91 02:56:15 GMT References: Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 16 In article richard@iesd.auc.dk (Richard Flamsholt S0rensen) writes: > According to the syntax, > x == 0 ? c = 2 : c = 4; > is illegal, because it is parsed as > (x == 0 ? c = 2 : c) = 4; > Everyone (well, almost - otherwise there wouldn't be any discussions >here on c.l.c :-) has acknowlegded, that this is correct. Then "everyone" is wrong. The LHS of an assignment expression must be a unary expression; thus, your suggested parse is incorrect. The example is unparsable according to the official C grammar. By judicious addition of parentheses you could make it parse in at least four distinct ways.