A curriosity in the C compiler...

Maarten Litmaath maart at cs.vu.nl
Sat Oct 29 02:32:35 AEST 1988


In article <530 at uvicctr.UUCP> sbanner1 at uvicctr.UUCP (S. John Banner) writes:
\/*
\	This is a quick test of the C compiler, for implied bracketing...
\This will determine if the expression "a = b == c" is parsed
\as "(a = b) == c" (which is correct), or as "a = (b == c)" (which
\is not).
\*/

The `=' operator has lower priority than `==', so the SECOND parsing is
correct. I thought this was VERY basic C knowledge...
(In case you find the precedence strange: think of `a' as a boolean in which
is stored if `b' and `c' are equal or not.)
-- 
George Bush:                          |Maarten Litmaath @ VU Amsterdam:
             Capt. Slip of the Tongue |maart at cs.vu.nl, mcvax!botter!maart



More information about the Comp.lang.c mailing list