"expandable" structs with last element declared using [1]
Dave Eisen
dkeisen at Gang-of-Four.Stanford.EDU
Fri Dec 29 03:57:05 AEST 1989
In article <15509 at haddock.ima.isc.com> karl at haddock.ima.isc.com (Karl Heuer) writes:
Six pieces of code starting from the obviously legal to the questionable.
I can't say whether or not it is legal, but if it isn't the problem is the
jump from [3] to [4].
All [0] to [1] relies on is the alignment of storage returned by malloc.
All [1] to [2] does is add to cp an integer that keeps it within the space
allocated by the malloc.
[2] to [3] is OK because the address of foo->baz[0] is (by definition))
offset (T, baz[0]) bytes away from foo.
But [3] to [4] takes the address of a "nonexistent" element, foo->baz[1]].
If this is legal, then that immediately answers the question as to whether
or not structs are "extendible".
And [4] to [5] is just the definition of the address of and pointer too
operators.
--
Dave Eisen Home:(415) 324-9366 / (415) 323-9757
814 University Avenue Office: (415) 967-5644
Palo Alto, CA 94301 dkeisen at Gang-of-Four.Stanford.EDU
More information about the Comp.std.c
mailing list