setjmp and typedef'd arrays; thoughts on &array
Tim Mann
mann at CSL-Vax.ARPA
Sun Oct 14 04:16:50 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
More information about the Comp.lang.c
mailing list