X3J11 Pleasanton meeting summary

Richard A. O'Keefe ok at goanna.cs.rmit.oz.au
Fri Oct 5 21:45:18 AEST 1990


In article <1990Oct3.162241.15245 at watdragon.waterloo.edu>, ccplumb at spurge.uwaterloo.ca (Colin Plumb) writes:
> In article <1990Oct2.164709.23887 at zoo.toronto.edu> henry at zoo.toronto.edu (Henry Spencer) writes:
> >>	struct foo x;
> >>	struct foo { int i; };
> >>	/* the above is strictly conforming; incomplete-type objects can
> >>	   be defined, so long as by the end of the translation unit the
> >>	   type becomes complete so that storage can then be allocated */

> > Betcha there isn't a compiler on Earth that will accept that today.
> > Everyone I know read the size as being needed at the time of the declaration.

> Taken.  $5.00?  Gcc 1.37.1 (VAX):

I note from The Annotated C++ Reference Manual (S 7.1.1, p 99)
"The name of a class can be used in an extern declaration.  Such
a declaration, however, cannot be used before the class has been
defined.  For example,
	struct S;
	extern S a;		// this is legal [my note]
	extern S f();
	extern void g(S);
	void h()
	    {
		g(a);		// error: S undefined
		f();		// error: S undefined
	    }
"

I have some difficulty with the interpretation, though.
Surely it is possible to produce a fragment of C code where you need
to know the size *before* the end of the translation unit?

	struct Erewhon a, b;

	void do_we_have_to_wait_until_the_end_of_the_unit_for_this_too()
	    {
		a = b;
	    }

	/* megabytes of source code follow ... */

I can see how to handle this; plant calls to a static void __assign_Erewhon()
function, and generate it as soon as you know the size.  Or call a generic
function, picking up the size from a static const, and plant code at the end
to initialise that.  But that could mean the difference between using a
single instruction (movc3, if size < 64k) or calling a procedure (size >).
It isn't quite so clear how to handle

	void surely_this_cannot_wait_so_long()
	    {
		struct Erewhon butler[20];
		...
		samuel(&butler[18]);
	    }

without some sort of runtime support that comes pretty close to being
alloca().
-- 
Fear most of all to be in error.	-- Kierkegaard, quoting Socrates.



More information about the Comp.std.c mailing list