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

T. William Wells bill at twwells.com
Sat Sep 16 06:04:40 AEST 1989


In article <3263 at solo5.cs.vu.nl> maart at cs.vu.nl (Maarten Litmaath) writes:
: bill at twwells.com (T. William Wells) writes:
: \...  a ? b : c = d
: \
: \can't be parsed as (a ? b : c) = d, since a ? b : c isn't a
: \unary-expression. It can, however, be parsed as a ? b : (c = d). As
: \far as I know, there are no compilers that this breaks on.
: \
: \Similarly one analyzes a && b = c:
:
: STOP!  Let's do precisely what you said, let's analyze a && b = c
: SIMILARLY:
:
:       a && b = c
:
: "can't be parsed as (a && b) = c, since a && b isn't a
: unary-expression. It can, however, be parsed as a && (b = c). As
: far as I know, there are no compilers that this breaks on."
:
: But wait!  This example breaks on EVERY compiler!

Yes. I was brain-dead on that one. I *know* how to read those damn
things. And I know that that bit of code won't work. But I was asleep
at the wheel. Somehow I reversed what I was going to say and just
continued writing with the negation substituted for what I intended.

Sorry.

You may take the flames I usually reserve for others as having been
directed at myself.

That paragraph should have said that a ? b : c = d is also not valid
because c = d is not a conditional-expression and so is not legal C.
And will not parse on any compiler I know of.

---
Bill                    { uunet | novavax | ankh | sunvice } !twwells!bill
bill at twwells.com



More information about the Comp.lang.c mailing list