Who says infinite structures are impossible?

William W Smith wws at siemens.UUCP
Mon Jul 23 22:53:53 AEST 1984


In the Berkeley Unix C compiler, the following declaration creates an
infinitely recursive structure:


struct x {
	int a;
	struct x { int b,c;} f;
        } s;


The compiler is more than happy to generate code for:

s.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.f.a = 727;

and, sizeof(struct x) returns 12 on a VAX.

Can anybody find a good use for this "feature?"

Bill Smith
princeton!siemens!wws



More information about the Comp.lang.c mailing list