Pcc bites it (was Re: programming puzzle (silly))

Scott Schwartz schwartz at shire.cs.psu.edu
Sun Mar 12 15:15:03 AEST 1989


In article <24820 at amdcad.AMD.COM>, tim at crackle (Tim Olson) writes:
>| > main(m,n){scanf("%d",&n);for(m=n>0^n>9;n&&m*=n--;);
>| > printf(m?"Answer=%d\n":"error\n",m);}

>Interesting -- the program *is* incorrect, because && has higher
>precedence than *= so it is parsed as:

Unfortunately, pcc accepts lots of things that aren't C.  No need to
be surprised this time!  Another fun example is "struct {int foo};".

>What do other compilers out there do?

Gcc 1.34 says "invalid lvalue in assignment".
-- 
Scott Schwartz		<schwartz at shire.cs.psu.edu>



More information about the Comp.lang.c mailing list