Structure pointer question

Wayne A. Throop throopw at xyzzy.UUCP
Mon Jun 20 04:25:39 AEST 1988


> firth at sei.cmu.edu (Robert Firth)
>> karl at haddock.ima.isc.com (Karl Heuer)
>>Although pointer-to-char and
>>pointer-to-int might have different internal representations, pointer-to-
>>-struct-foo and pointer-to-struct-bar cannot%.
> This makes no sense to me.  Surely a pointer to a struct whose only
> component is of type X will use the same representation as a pointer
> to a plain X.  Hence if *X and *Y differ, so will *struct{X} and
> *struct{Y}.

Actually, I think you're both wrong.  Sort of.

First, a pointer to a struct containing only a char and a pointer to a
char needn't have the same format to be standard conforming.  In fact,
DG's C compiler does this very thing: pointer-to-char and
pointer-to-struct-containing-only-a-char have different formats.  

But on the other hand, I'm not aware of any requirement in draft X3J11
that all struct pointers have the same format.  It is a good idea to
make it so, because of quite a bit of existing code, and so many
compilers do, indeed, make it so.  But they needn't, as far as I know.

In a footnote in Karl's posting, he said that he thought he could
construct an argument that draft X3J11 does indeed require this.  I'd be
interested to see this argument... As I said, I don't see how it could
be constructed.  But, as always, I could be missing some fine print.

--
"You don't think my theory holds water?"
"A bathtub will hold water.  A canteen is usually sufficent."
        --- exchange between Laurent Michaelmas and Domino
-- 
Wayne Throop      <the-known-world>!mcnc!rti!xyzzy!throopw



More information about the Comp.lang.c mailing list