Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!cmcl2!philabs!mcnc!rti-sel!sas!jjr From: jjr@sas.UUCP (Jack Rouse) Newsgroups: net.lang.c Subject: Re: typedef bug summary Message-ID: <131@sas.UUCP> Date: Sun, 27-Jul-86 16:22:42 EDT Article-I.D.: sas.131 Posted: Sun Jul 27 16:22:42 1986 Date-Received: Mon, 28-Jul-86 05:04:44 EDT References: <265@sdchema.sdchem.UUCP> Organization: SAS Institute Inc. Cary, NC Lines: 20 Summary: Why it happens... The problem described by Tom Stockfisch, where a typedef identifier cannot be reused as a variable identifier in a nested scope is common to many C compilers which use a formal grammar for parsing. In order to handle ambiguities in the C grammar, it is necessary for these compilers to regard typedef names and normal identifiers as different lexical types. Consider the following code: int i, bar; ... i = (foo)&bar; If foo is an int variable, the last statement performs a bitwise and of foo and bar. If foo is a typedef name (as in "typedef int foo;"), however, then the last statement takes the address of bar and casts it to type foo. To resolve this ambiguity, PCC derived compilers pass information back from the parser to the lexical scanner when a typedef name is created so that it will not be treated as a regular identifier. What PCC has neglected to do, however, is provide a means to redeclare the name in a inner scope. -- -- Jack Rouse, SAS Institute Inc., Box 8000, Cary, NC 27511 USA USENET: mcnc!rti-sel!sas!jjr TELCO : (919) 467-8000