?:
Matt Squires
squires at eecs.nwu.edu
Thu Feb 8 09:22:11 AEST 1990
In comp.lang.c, phil at 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 at eecs.nwu.edu
More information about the Comp.lang.c
mailing list