egregious C compiler bug

utzoo!decvax!harpo!utah-cs!utah-gr!thomas utzoo!decvax!harpo!utah-cs!utah-gr!thomas
Fri Feb 25 14:00:37 AEST 1983


Just encountered this one the other day (not my code, a friend came up
with it).  I don't know if it's in all C compilers, we're using the
(Berkeley) pcc.  Try the following program:

	main()
	{
		bar( 1, 2, 3, 4 );
	}

	/*  You can't call this one */
	foo( a, b );

	/* This one gets ALL 4 args! */
	bar( c, d )
	{

		printf("a=%d, b=%d, c=%d, d=%d\n", a, b, c, d);
	}

If you run it, it prints
	a=1, b=2, c=3, d=4

and the function foo is NOT defined!

=Spencer



More information about the Comp.lang.c mailing list