Problem report: Struct aliasing problem causes Thread_Ready_Chain corruption in 4.6.99.3

Eric Norum norume at aps.anl.gov
Mon Dec 4 22:20:16 UTC 2006


On Dec 4, 2006, at 4:11 PM, Till Straumann wrote:

> The C99 standard invents special, magic semantics for 'memcpy'  
> 'malloc' etc.
> so that allocated memory can be 'assigned' an 'effective type'.
>
> To me, this shows how inherently broken the alias rule is.
> There are many occasions where you might want to provide
> an allocator of some kind (e.g., allocate a buffer from a pool)
> w/o knowing what type of object the item finally should represent.
>
> However, it seems to me that you cannot 'c99-legally' write
> such an allocator.
>
> I can't figure out a way to, e.g., allocate a (generic) buffer,
> read data into it and figuring out later that it is a UDP packet
> and then access it as as 'struct udp_packet'.
>

Does storing through a (char *) pointer not work for this?  I was  
under the impression that memory accessed through such a pointer had  
to be treated by the compiler as possibly aliasing with any other  
pointer access.


-- 
Eric Norum <norume at aps.anl.gov>
Advanced Photon Source
Argonne National Laboratory
(630) 252-4793





More information about the users mailing list