[net.lang.c] typedef scope messed up in pcc?

tps@sdchem.UUCP (Tom Stockfisch) (06/04/86)

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

ark@alice.UucP (Andrew Koenig) (06/06/86)

> 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.

Yes it is.