Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!topaz!nike!ucbcad!ucbvax!sdcsvax!sdchem!tps From: tps@sdchem.UUCP (Tom Stockfisch) Newsgroups: net.lang.c Subject: typedef bug summary Message-ID: <265@sdchema.sdchem.UUCP> Date: Thu, 24-Jul-86 14:09:23 EDT Article-I.D.: sdchema.265 Posted: Thu Jul 24 14:09:23 1986 Date-Received: Fri, 25-Jul-86 06:42:06 EDT Reply-To: tps@sdchema.UUCP (Tom Stockfisch) Organization: Chemistry Dept, UC San Diego Lines: 45 Subject: typedef bug summary ORIGINAL ARTICLE: 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 SUMMARY OF RESPONSES: RESPONDENT COMPILERS WITH BUG COMPILERS WITHOUT BUG Andrew Koenig ark@alice.UucP all pcc compilers Dan Jones (pcc based) Unisoft Green Hills