Path: utzoo!utgpu!watserv1!watmath!iuvax!mailrus!accuvax.nwu.edu!nucsrl!squires From: squires@eecs.nwu.edu (Matt Squires) Newsgroups: comp.lang.c Subject: Re: ?: Message-ID: <3950015@eecs.nwu.edu> Date: 7 Feb 90 22:22:11 GMT References: <6200014@ux1.cso.uiuc.edu> Organization: Northwestern U, Evanston IL, USA Lines: 24 In comp.lang.c, phil@ux1.cso.uiuc.edu writes: > Do any compilers accept this kind of syntax (which as far as I can tell is > bogus C since ?: does not yield an lvalue, but is not ambiguous): > > ( a == b ? x : y ) += z; /* x and y are lvalues */ > > as equivalent to: > > if ( a == b ) x += z; else y += z; Sure, GNU's GCC does. From the GCC info page: < A conditional expression is a valid lvalue if its type is not void and the < true and false branches are both valid lvalues. For example, these two < expressions are equivalent: < < @example < (a ? b : c) = 5 < (a ? b = 5 : (c = 5)) < @end example Matt "Local GNUisance" S. squires@eecs.nwu.edu