Problem report: Struct aliasing problem causes Thread_Ready_Chain corruption in

Kim Barrett kab at
Mon Dec 4 13:59:46 CST 2006

At 8:30 AM -0800 12/4/06, Till Straumann wrote:
>While the optimization is optional, programs that violate the
>aliasing rule are unfortunately not C99 compliant - the
>standard does *not* declare this rule optional, unfortunately.

De-lurking briefly, in this very interesting discussion, to ask:

Am I confused, or is POSIX riddled with strict-aliasing violations?

I'm thinking, for example, of the struct sockaddr variants, where
one allocates space for a sockaddr_in or sockaddr_un or whatever,
but often passes it around as a (cast to) sockaddr*. While sockaddr
has a "common initial sequence" (C99 para5) with sockaddr_in
&etc, there is nothing I can find that would indicate that they are
"compatible types" (C99 6.2.7 &etc), and 6.7.7 example 2 seems to
explicitly indicate that they are not.

And since the aliasing rules are written in terms of "compatible
types", this makes me suspicious.

More information about the rtems-users mailing list