http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46488

--- Comment #24 from Richard Guenther <rguenth at gcc dot gnu.org> 2010-11-29 
13:39:02 UTC ---
(In reply to comment #18)
> Using
> 
> #define APR_RING_SENTINEL(hp, elem, link)                \
>     (struct elem *)((char *)(hp) - APR_OFFSETOF(struct elem, link))
> 
> should be safer wrt strict aliasing.

not really.  But using

typedef struct elem elem_ __attribute__((may_alias));
#define APR_RING_SENTINEL(hp, elem, link) \
    (struct elem_ *)((char *)(hp) - APR_OFFSETOF(struct elem, link))

would be safe wrt strict aliasing (if the pointer is only dereferenced
directly and not casted to another pointer type before, of course).

Reply via email to