typedef bug summary

Tom Stockfisch tps at sdchem.UUCP
Fri Jul 25 04:09:23 AEST 1986


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 at alice.UucP		all pcc compilers

Dan Jones		(pcc based) Unisoft		Green Hills



More information about the Comp.lang.c mailing list