Union element alignment query

Henry Spencer henry at zoo.toronto.edu
Sun Nov 18 09:12:17 AEST 1990


In article <810001 at hplred.HP.COM> curry at hplred.HP.COM (Bo Curry) writes:
>union {
>   FOOTYPE	a[4];
>   BARTYPE        b;
>} combo;
>
>Does the standard guarantee that (void *)(&combo.a[0]) == (void *)(&combo.b) ?

It guarantees (3.5.2.1) that a pointer to the union points to each of its
members, after suitable conversion.  That is not *quite* what you are
asking, but I think it would take a seriously bizarre implementation to
do otherwise.  It may be possible to prove your equality, although it
would take non-trivial reasoning.
-- 
"I don't *want* to be normal!"         | Henry Spencer at U of Toronto Zoology
"Not to worry."                        |  henry at zoo.toronto.edu   utzoo!henry



More information about the Comp.lang.c mailing list