Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!ucbvax!sdcsvax!sdchem!tps From: tps@sdchem.UUCP (Tom Stockfisch) Newsgroups: net.lang.c Subject: typedef scope messed up in pcc? Message-ID: <234@sdchema.sdchem.UUCP> Date: Wed, 4-Jun-86 12:10:56 EDT Article-I.D.: sdchema.234 Posted: Wed Jun 4 12:10:56 1986 Date-Received: Sat, 7-Jun-86 05:35:29 EDT References: <697@bu-cs.UUCP> <275@zeus.UUCP> Reply-To: tps@sdchema.UUCP (Tom Stockfisch) Organization: Chemistry Dept, UC San Diego Lines: 32 All the C compilers I have access to (4.2 and 4.3 on VAXes, and 4.2 on Celerity) reject the following legitimate program. Try this out on your compiler: typedef float distance; main() { /*###6 [cc] illegal type combination%%%*/ auto int distance; /*###8 [cc] unknown size%%%*/ /*###8 [cc] cannot recover from earlier errors: goodbye!%%%*/ /*###8 [cc] syntax error%%%*/ /*###8 [cc] warning: illegal combination of pointer and integer, op =%%%*/ distance = 1; printf( "distance = %d\n", distance ); } The float typedef's scope should be hidden by the local int's declaration so that the program *is* legal. Lest you think this isn't guaranteed, this program is actually an example from K&R p. 206. It is also accepted by the yacc grammar I got off the net based on the ANSI 4/85 draft. So here's the question: is this bug present in *all* pcc compilers, or at least in a lot of compilers? If so, I better stop using lower case letters for typedefs to avoid clashes with local variables. If people send me the results of this program using their compiler, I'll post a summary of which compilers get it right, and which wrong. --Tom Stockfisch, UCSD Chemistry