PCC <-> scope rules for \"typedef\" ??

bhorn at brl-tgr.ARPA bhorn at brl-tgr.ARPA
Mon Dec 10 23:41:56 AEST 1984


    You are indeed correct - PCC does  indeed  barf  on  your  example
(and further, on the very example given on page 206 of K&R).  Further,
Ritchie's compiler exhibits the same incorrect behaviour.  Although  I
cannot imagine what Kernighan and  Ritchie  were  thinking  when  they
wrote the Book, it is clear that they did NOT implement what they said
they should have done.  I will go one step further; I have tested many
other C compilers from various vendors and NONE of them implement this
feature of the language correctly.  One vendor,  after  giving  me  an
arguement on this very point, finally  conceded  that,  indeed,  their
compiler was wrong.  In their own defense, the  vendor  claimed,  "But
Bell's compiler has the same bug..."

    Given all of the above, a friend of mine and I decided to get this
right, for once!  We have just finished writing a portable C  compiler
that does indeed treat this (and other) examples correctly.

    For other compilers, most will  allow  the  redeclaration  if  the
redeclared identifier is NOT the first indentifier in  the  declarator
list.  As for your case with "long(intType);" I have no idea  why  PCC
gives the error message it does, but I am not at all surprised that it
parses that incorrectly too.

						    Brian D. Horn
						    bhorn at cit-{750,vax,20}


P.S. For real fun with PCC, try:

int a, b;
int c = &a - &b;



More information about the Comp.lang.c mailing list