[comp.lang.c] precedence of && =

bph@buengc.BU.EDU (Blair P. Houghton) (09/15/89)

In article <3242@solo12.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes:
>gcc (ANSI or what?) does accept
>
>	0 ? 0 : i = 0
>
>but it does NOT accept
>
>	0 && i = 0

Why should it?  It's an expression.  Paraphrasing from K&RI (the
Talmud, cats; so call me a fundamentalist) the order of evaluation is
undefined except by the explicit precedence and grouping of the
operators. (A.7, p.185)

Any compiler that doesn't think that `0 && i' is trying to be an
lvalue for `result = 0' isn't applying the word of god.

>In fact, I've never used a C compiler that accepted the latter construct.
>Of course I fully agree it should be accepted.

Eh?  And cause rampantly creeping unmaintainability?  Hordes of confused
students wondering what was going to happen when they had followed the
letter of the book?

				--Blair
				  "Quote me some K&RII."