Problem report: Struct aliasing problem causes Thread_Ready_Chain corruption in

Aaron J. Grier aaron at
Tue Dec 5 00:38:02 UTC 2006

On Mon, Dec 04, 2006 at 03:14:49PM -0800, Till Straumann wrote:
> I believe you would have to declare a union
> union clumsy_union {
>    Pbuf                       raw_buffer;
>    struct udp_packet packet;
> } xxx;

unions have enough space to hold all the member datatypes, but is there
anything in the standard that says that the members actually have to
occupy the same memory space, or how they are actually overlayed?

K&R says "It is the responsibility of the programmer to keep track of
what type is currently stored in a union; the results are machine
dependent if something is stored as one type and extracted as another."

what does c99 say?

> The problem with this approach is that you don't know upfront that
> your data is a udp packet.
> So you'd need unions of all possible variants at each layer of a
> protocol stack.

ignoring the union overlay properties mentioned above, couldn't (char *)
be used as the lowest common denominator?  (alignment issues

  Aaron J. Grier  |   Frye Electronics, Tigard, OR   |  aaron at

More information about the users mailing list