Array of unions

rmc at lanl.ARPA rmc at lanl.ARPA
Sat Jun 29 01:19:18 AEST 1985


> 
> 	I defined an array of unions as follows:
> 
> 	    typedef union {
> 		unsigned char *bytes;
> 		unsigned long *words;
> 	    } block;
> 
> 	    block sched[NKEYS];
> 
> 	Now if I try to pass sched[i] as a parameter,
> the C compiler bombs with "Fatal error in /lib/ccom".

	Here's an example of a program that didn't
compile under 4.2/4.3bsd (VAX).  The program DID
compile on a SUN, or with the portable C compiler
under SUMacC.

#define NKEYS 20
	    typedef union {
		unsigned char *bytes;
		unsigned long *words;
	    } block;


	main()
	{
	block sched[NKEYS];
	int i;
	i= 4;
	bar(i, sched);
	}

	bar (i, sched) block sched[];
	{
	foo(sched[i]);
	}

	foo (junk) block junk;
	{
	printf("%d\n",junk.bytes);
	}

			-- R. Martin Chavez
			(chavez at lanl.ARPA)



More information about the Net.bugs mailing list