precedence of && (was: precedence of ?:)

Tom Karzes karzes at mfci.UUCP
Fri Sep 22 04:05:05 AEST 1989


Neither of the following are legal because conditional expressions (?:) are
not regarded as lvalues:

    (a ? b : c) = d
    (a ? *b : *c) = d

However, the following is legal since indirection expressions (*) are legal
lvalues:

    *(a ? b : c) = d

I personally don't see why ?: expressions can't be lvalues, provided the
second and third operands have the same type.  For example, the following
would be legal, with result type int:

    int a, b, c[10], d, i;
    ...
    (a ? b : c[i]) = d;

But the following would be illegal:

    int a, b, d;
    double c;
    ...
    (a ? b : c) = d;

Oh well...



More information about the Comp.lang.c mailing list