precedence of && (was: precedence of ?:)
David Goodenough
dg at lakart.UUCP
Wed Sep 20 01:11:36 AEST 1989
OK, you say:
a ? b : c = d
can't be parsed sensibly as
(a ? b : c) = d
which I tend to agree with: the term in parentheses is not an lvalue.
But what about:
int a;
char *b, *c, d;
.
.
.
a ? *b : *c = d
Now, can that legally be done?? Whatever value a has (TRUE or FALSE) the
a ? *b : *c construct could be considered an lvalue (OK, so you need a
slightly twisted mind to see it :-) ) And it's a somewhat academic question,
since the * (indirection) operator distributes over the ?: operator: the
above could equally well be written as:
*(a ? b : c) = d
which had better be fair game, otherwise I'm going to complaing to my
compiler vendor.
--
dg at lakart.UUCP - David Goodenough +---+
IHS | +-+-+
....... !harvard!xait!lakart!dg +-+-+ |
AKA: dg%lakart.uucp at xait.xerox.com +---+
More information about the Comp.lang.c
mailing list