[net.lang.c] C compiler bug from ravi, Fairchild Research

harris@csu-cs.UUCP (06/17/83)

Note that your local variable declarations for c and d:
	char *c[], *d[];
don't allocate any space.  This defines c and d to be arrays of
pointer to char, with dimension 0 since there is no initialization list.

The effect is that accesses to c and d are overlayed with whatever
local variables are defined afterward.  I find it surprising that
any compiler produces the output you expected.

My question is should such array definitions, with no dimension
specified and no following initialization list be allowed at the
local level?  Should the definition generate a compiler error or
is this "overlaying" of local variables considered a "feature"?

As a simpler example, try the following:

	main() {
		char s[];
		int i;

		i = 0x12345678;
		s[0] = 'a';

		printf("i = 0x%08x\n",i);
	}

On the compilers I have tried this generates: i = 0x61345678


K. Harris
ucbvax!hplabs!hpfcld!kah