Path: utzoo!attcan!uunet!twwells!bill From: bill@twwells.com (T. William Wells) Newsgroups: comp.lang.c Subject: Re: precedence of ?: Message-ID: <1989Sep30.050747.17379@twwells.com> Date: 30 Sep 89 05:07:47 GMT References: <1265@gmdzi.UUCP> <658@anvil.oz> Organization: None, Ft. Lauderdale, FL Lines: 34 In article <658@anvil.oz> michi@anvil.oz (Michael Henning) writes: : In article <1265@gmdzi.UUCP>, wittig@gmdzi.UUCP (Georg Wittig) writes: : > How should : > 0 ? 0 : i = 0 : > be interpreted? : > : > 1) as (0) ? (0) : (i=0) : > resulting in a (strange but) legal expression : > : > or 2) as (0 ? 0 : i) = 0 : > resulting in a syntax error : > ? : : The correct interpretation is : : (0 ? 0 : i) = 0 : : because the precedence of ':' is higher than that of '='. No it isn't. Because the LHS of an assignment operator is a unary expression, not a conditional expression. Precedence rules are not adequate for analyzing C expressions. It is not the case (as I'm assuming that Mr. Henning is asserting) that the expression is parsed "(0 ? 0 : i) = 0" and then rejected because "0 ? 0 : i" is not an lvalue. Instead, there is no valid parse of the expression and the lvalueness of "0 ? 0 : i" is not relevant. Didn't we just finish beating this into the ground? --- Bill { uunet | novavax | ankh | sunvice } !twwells!bill bill@twwells.com