Re: casting of structs

From: Peter Pichler (pichlo7_at_pobox.sk)
Date: 12/29/03


Date: Mon, 29 Dec 2003 21:30:30 -0000

Christopher Benson-Manica wrote :
> Peter Pichler spoke thus:
>
> > No. A pointer to a structure can be portably /converted/ to a pointer to
the
> > first element of the structure and back.
>
> FMI, can you quote the portion of the Standard that allows this?
> Consider my curiousity piqued :)

Ehm, did I manage to make a fool of myself /again/? ;-)

No quote, just my simplified interpretation of 6.7.2.1:
...
13 Within a structure object, the non-bit-field members and the units in
   which bit-fields reside have addresses that increase in the order in
   which they are declared. A pointer to a structure object, suitably
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   converted, points to its initial member (or if that member is a
bit-field,
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   then to the unit in which it resides), and vice versa. There may be
                                          ^^^^^^^^^^^^^^
   unnamed padding within a structure object, but not at its beginning.



Relevant Pages

  • Re: Address of a structure and its first field
    ... which bit-fields reside have addresses that increase in the order in ... A pointer to a structure object, ... points to its initial member (or if that member is a ... have an appropriate newsgroups line in your header for your mail to be seen, ...
    (comp.lang.c.moderated)
  • Re: Ban IP cua CTHN / VPTT ::: Poll
    ... Mana: ... Quote ... Member ... Posts: ...
    (soc.culture.vietnamese)
  • Re: Largest Set in ZFC?
    ... axioms" but rather a set (the universe of the model) AND a RELATION ... That's your quote above. ... not required that the set have w as a member so it is not required ... been talking about is a successor inductive set; ...
    (sci.logic)
  • Re: The way forward
    ... In one post Mr. Heenan "Quote I do not suffer fools gladly un Quote)" does one take this to mean that Mr. Heenan does not suffer his own life, what a sad existence this fellow must have. ... It is complete berks I have no time for, except you of course and I really don't know myself why I bother to wase it on your goodself....old bean. ... Trouble is, my dear old fruitcake, you ain't a prospective member. ...
    (uk.rec.naturist)
  • Re: Undefined behavior - 2 queries
    ... at compilation time. ... you'll find that no padding may be inserted before the ... first member of a structure. ... Within a structure object, the non-bit-field members and the units ...
    (comp.lang.c)