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

News system news at ism780c.isc.com
Sat Sep 16 07:40:55 AEST 1989


In article <3263 at solo5.cs.vu.nl> maart at cs.vu.nl (Maarten Litmaath) writes:
: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!

Unfortunately, pcc based compilers accept a && b += c.  They do reject
a && b = c however.  Writing a grammer for the language as was done by ANSI
helps avoid these funnies.

    Marv Rubinstein



More information about the Comp.lang.c mailing list