On 29 February 2012 16:47, Glenn Fowler <[email protected]> wrote:
>
> are there any .c files in <your-favorite-os/library-layer> that must be 
> compiled
> with the local flavor of no-strict-aliasing?

Opensolaris libc, BSD libc and AFAIK even glibc are all clean of
constructs which violate C99.

> my guess would be to look at the malloc implementation
>
> is it simply a matter of waving union's over the code to keep cXX happy?
>
>        union
>        {
>                Specific_t*     specific;
>                void*           generic;
>        } u;
>
>        u.generic = some_buffer_pointer;
>        u.specific->im_ok_with_c99 ? yes : no;

http://cellperformance.beyond3d.com/articles/2006/06/understanding-strict-aliasing.html
says that doing this via union is undefined but may work for C99:
[quote]Strictly speaking, reading a member of a union different from
the one written to is undefined in ANSI/ISO C99 except in the special
case of type-punning to a char*, similar to the example below: Casting
to char*. However, it is an extremely common idiom and is
well-supported by all major compilers. As a practical matter, reading
and writing to any member of a union, in any order, is acceptable
practice.[/quote]

I recall that the use of volatile unions is a solution which conforms
to the standard but I couldn't find a link to verify this.

Ced
-- 
Cedric Blancher <[email protected]>
Institute Pasteur
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to