setjmp and typedef'd arrays; thoughts on &array

Stew Rubenstein stew at harvard.ARPA
Sun Oct 21 15:37:46 AEST 1984


> > C purportedly handles arrays as if they were blocks of data and pointers.
> > However, it doesn't, quite.  The declaration
> > 
> > 	char **foo, bar[10];
> > 
> > should allow me to say
> > 
> > 	foo = &bar;
> > 
> > later on.h, since bar should be a pointer to char.  Unfortunately, bar
> > is what I call a VIRTUAL pointer -- it assembles as a literal (look at
> > your compiler's output).  To work correctly, it would have to assemble
> > to a constant pointer which always points to a particular block of memory,
> > in which case the above would work.  (Notice that the above is essentially
> > the jmp_buf, expanded.)  Instead, there is no such thing as &bar because
> > bar is not a variable, it is a literal.
> 
> This is not an anomaly, and there is no reason to invent the term "virtual
> pointer".  In your example, "bar" is a constant of type pointer-to-char.  As
> a constant, it does not have an address.  It is no more legitimate to write
> &bar and expect to get the address of a cell containing bar's value, than it
> would be to write &1 and expect to get the address of a cell with the value
> 1 in it.
> 
> I'm not going to try to respond to the other points in your message or the
> other discussion that's been going on in this area just now.
> 
> 	--Tim

Ah, but Vax/VMS VAX-11 C *does* allow &1, meaning the address of a cell with
a 1 in it.  However, only for the special case of function call argument lists
so that you can pass a constant by reference to languages that don't have
call-by-value.
-- 
-----------------------
Stew Rubenstein     UUCP: ihnp4!harvard!stew
Harvard Chemistry   ARPA: stew at harvard



More information about the Comp.lang.c mailing list