Structure alignment question

karl at haddock karl at haddock
Tue Sep 9 06:48:00 AEST 1986

rbbb at rice.EDU (David) writes:
>C compilers that I have seen supporting structure-valued functions pass a
>hidden parameter to the function containing the address to store the result.
>Can a compiler assume that the storage for the result is word-aligned?
>(That is, can a compiler make the same assumptions when returning a
>structure that it does when assigning a structure?)

Certainly.  It can make this assumption for *any* expression of type "pointer
to struct foo", whether it's explicit or (as in this example) generated by
the compiler.  *All* instances of a type (including those generated by a
pointer dereference) have the alignment of that type.  The user can sometimes
circumvent this (type punning with casts or unions), but the result is

Karl W. Z. Heuer (ima!haddock!karl; karl at, The Walking Lint

More information about the Comp.lang.c mailing list